+ Reply to Thread
Results 1 to 4 of 4

VBA code doesn't unprotect sheet but Excel does

  1. #1
    Registered User
    Join Date
    08-13-2009
    Location
    London, England
    MS-Off Ver
    1
    Posts
    5

    VBA code doesn't unprotect sheet but Excel does

    I am working with several workbooks that are protected. I want to loop through them, do some stuff on each one and print out a copy. I have inserted code to unprotect the sheet with the correct password. However, an error occurs when the code tries to edit the workbook because, in reality, it has not been unprotected at all. While in debug mode, I can go and unprotect the sheet manually with Excel (with the same password) and it is unprotected. However, I inserted an error handler that tries to unprotect the sheet again. This causes the code to just continuously loop and never unprotects the sheet. Here is my code:

    Please Login or Register  to view this content.
    Any help would be greatly appreciated. Thanks.

  2. #2
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: VBA code doesn't unprotect sheet but Excel does

    Please Login or Register  to view this content.
    Your comment says it unlocks the worksheet... which worksheet? You need to specify which worksheet you are trying to unlock

    Equally you will need to specifiy which sheet you are referring to with this statment:
    Please Login or Register  to view this content.
    Something like this:
    Please Login or Register  to view this content.
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for you

  3. #3
    Registered User
    Join Date
    08-13-2009
    Location
    London, England
    MS-Off Ver
    1
    Posts
    5

    Re: VBA code doesn't unprotect sheet but Excel does

    Wow, I feel stupid. I intended to use the "ActiveSheet" property and instead used "ActiveWorkbook." Thanks for your help.

  4. #4
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: VBA code doesn't unprotect sheet but Excel does

    No worries, it's usually the little things that trip us up

    If this is now solved please edit your original post, click [Go Advanced], and then from the prefix dropdown box select 'SOLVED'.

    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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