+ Reply to Thread
Results 1 to 5 of 5

Looking for the Code for my Macro to unprotect my work sheets

  1. #1
    Registered User
    Join Date
    10-22-2012
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    65

    Looking for the Code for my Macro to unprotect my work sheets

    I have an excel that has Marco being run by using a command button to create my pdf's. But my work sheets are Protected by a password. Is there a code for me to insert in order for the worksheet become unprotected for it to do the commands I am requesting?

    Thank you -

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Looking for the Code for my Macro to unprotect my work sheets

    don't you know the password?
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    10-22-2012
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    65

    Re: Looking for the Code for my Macro to unprotect my work sheets

    Yes I know the password. My workbook is Protected, and when the end users get the workbook they are to click the command button that has a macro built in for it to save the book in a specific folder and generate pdf reports. Will my macro is set up to delete blank lines and it will not work if the sheets are protected. So I am looking for a code that would unprotect the sheet first, for it then to delete the blank lines, then create the pdf reports.

    I think the code would be this...

    Please Login or Register  to view this content.
    But I'm not sure since I am having issue now with my code to delete the lines.

    Thank you....

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Looking for the Code for my Macro to unprotect my work sheets

    That works. You don't have to unprotect at the workbook level. I would recommend you use the actual sheet name instead of ActiveSheet. And don't forget to re-protect:
    Please Login or Register  to view this content.
    By the way, if you put a password into your code, now you should password-protect the code.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  5. #5
    Registered User
    Join Date
    10-22-2012
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    65

    Re: Looking for the Code for my Macro to unprotect my work sheets

    Reply good idea in protecting the code - how would password protect the code?
    Thank you for the correct code to allow my workbook to function better.

  6. #6
    Registered User
    Join Date
    10-22-2012
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    65

    Re: Looking for the Code for my Macro to unprotect my work sheets

    Figured out how to protect my code.
    In the VB editing window, under Tool select VBAProject Properties, select protect tab.

+ 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