+ Reply to Thread
Results 1 to 7 of 7

Using a password within a macro

  1. #1
    Registered User
    Join Date
    08-30-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    78

    Using a password within a macro

    I'm hoping this is an easy answer.

    I don't have the expertise in VBA to write a macro so I'm simply recording one.

    However, as part of the macro sequence, the worksheet needs to be unprotected and then, before the macro finishes, it needs to be protected again.

    I've tried a couple of different approaches; just clicking on "unprotect sheet" and typing in the password while recording the macro doesn't work. I tried storing the password in a hidden cell and then, as part of the macro, copying it and then pasting it in the "unprotect sheet" command.

    Neither of these work - the macro simply hangs at the command line for the password when unprotecting the worksheet.

    Is there a simple way past this problem?

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Using a password within a macro

    https://msdn.microsoft.com/en-us/lib.../ff840611.aspx

  3. #3
    Registered User
    Join Date
    08-30-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Using a password within a macro

    Hi cytop,

    I'm not sure how this link answers my question.

    I don't need help protecting the worksheet (I don't think) - just being able to unprotect it with a recorded macro.


    I'm probably missing something so please let me know.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Using a password within a macro

    Hi,

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Registered User
    Join Date
    08-30-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Using a password within a macro

    Hi Richard,

    Is that a command line I need to have in the macro?

    As I said, I don't have the expertise in VBA to write a macro so I'm not sure what my next steps would be with this line.


    Does this mean there's no way to record a macro sequence that includes unprotecting and protecting a worksheet?

  6. #6
    Registered User
    Join Date
    08-30-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Using a password within a macro

    As it turns out that must be simple since even I was able to work it out.

    Thanks - it works perfectly.

  7. #7
    Registered User
    Join Date
    08-30-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Using a password within a macro

    Richard,

    I'm going to mark this post as solved but if you could also have a look at a similar question in the post I've linked below that would be appreciated.

    Thanks again for your help on this post.

    http://www.excelforum.com/showthread.php?t=1170369

+ 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. Replies: 1
    Last Post: 05-27-2014, 02:40 PM
  2. macro that inputs the password on a password protected document
    By dandavis1 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 04-09-2014, 10:12 AM
  3. Replies: 6
    Last Post: 02-09-2013, 03:06 AM
  4. password protection-is there anyway to put a password on running a macro in excel?
    By Solarissf in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-12-2008, 10:06 AM
  5. [SOLVED] How to see macro code of a password protected macro without a password?
    By Dmitry Kopnichev in forum Excel General
    Replies: 5
    Last Post: 10-27-2005, 05:05 AM
  6. [SOLVED] How to see macro code of a password protected macro without a password?
    By Dmitry Kopnichev in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-27-2005, 05:05 AM
  7. How to see macro code of a password protected macro without a password?
    By Dmitry Kopnichev in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-27-2005, 05:05 AM

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