+ Reply to Thread
Results 1 to 9 of 9

1004 error in protected view

  1. #1
    Registered User
    Join Date
    01-22-2016
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    5

    1004 error in protected view

    I have an Excel 2010 template with extensive VBA code which runs without errors when fired up from any location on my laptop. When I test accessing it through my organisation's intranet (it needs to be accessed by around 300 staff), it downloads to the Downloads folder and, when opened from there it is in Protected View and throws a 1004 error in the WorkBook_AfterOpen procedure. Disabling opening in Protected View is not an option. If I then retry to open the file, there is no error.

    It may be a timing error as described here:

    http://answers.microsoft.com/en-us/o...d-7a6204704d86

    I've tried implementing the OnTime method without success. Here is my code:

    Please Login or Register  to view this content.
    Can anyone help? I'm pretty sure that my code is bug-free as it runs fine when fired up in non-protected view from the desktop. I think that it's a higher-order Excel timing problem.

    Thanks in advance

    Iain

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: 1004 error in protected view

    What's the error message?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    11-28-2005
    Location
    Dover, England
    Posts
    172

    Re: 1004 error in protected view

    What is the level of security set for macros on the 300 users PC's.

  4. #4
    Registered User
    Join Date
    01-22-2016
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    5

    Re: 1004 error in protected view

    Run-time error 1004: Method 'OnKey' of Object '_Application' failed

  5. #5
    Registered User
    Join Date
    01-22-2016
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    5

    Re: 1004 error in protected view

    Largely unknown to me but, as the file is downloaded to the Downloads folder, I assume that this folder is not a trusted location on all users' computers. For pretty sensible reasons my organisation will not give Downloads folders a trusted location status. Is there a way to change the downloads folder for this application to some other folder which could be given trusted status?

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: 1004 error in protected view

    Iain

    That doesn't really sound like a timing issue to me, sounds more likely to be something to do with the protected status of the workbook.

    What happens if the workbook is downloaded to another folder and opened from there?

  7. #7
    Registered User
    Join Date
    01-22-2016
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    5

    Re: 1004 error in protected view

    Norie and Tellm

    Thanks for your responses.

    I've done a bit more research on this and it seems that it's a known issue in excel 2010. This url gives details:

    https://support.microsoft.com/en-us/kb/2745652

    The KB article gives some sample code. My questions now are these: can the sample code be implemented as is or does it have to be customised for my own identifiers (workbook name etc); do the open and activate events code in the sample replace the standard Workbook_Open and Workbook_Activate events or do they have to be called explicitly?

    Thanks in advance.

    Iain

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: 1004 error in protected view

    Iain

    The sample code on that page appears to be for an add-in.

    Have you tried the suggestion of using the workbook's Activate event instead of its Open event?

  9. #9
    Registered User
    Join Date
    01-22-2016
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    5

    Re: 1004 error in protected view

    Norie

    Any idea how I call this code?

    Iain

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Run Time Error 1004 - You cannot use this command on a protected sheet
    By frogboy in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 12-11-2012, 07:59 AM
  2. Error:1004 When Password Protected VBA
    By Gopal Veeranala in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-17-2012, 12:14 PM
  3. [SOLVED] run time error 1004, cell or chart is protected.
    By ndtsteve in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-09-2012, 12:42 PM
  4. Run-time error '1004' ... But only when the worksheet is protected?
    By jonvanwyk in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-07-2012, 06:22 AM
  5. VB run time error 1004 on protected sheet
    By Twaddy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-27-2010, 05:07 PM
  6. Protected sheets w/macros giving runtime error 1004
    By cedarhill in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-03-2009, 07:59 AM
  7. Run-time error 1004 when sheet is protected
    By AJ. in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-05-2008, 10:33 PM
  8. [SOLVED] run time error 1004 on protected worksheet when I try to run macro
    By dtg_denver in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-12-2005, 09:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1