+ Reply to Thread
Results 1 to 2 of 2

Not able to execute the macro when macro is password protected

Hybrid View

  1. #1
    Registered User
    Join Date
    12-17-2013
    Location
    Bangalore
    MS-Off Ver
    Excel 2010
    Posts
    1

    Lightbulb Not able to execute the macro when macro is password protected

    I have a piece of excel macro. When I protect my macro with a password, I am not able to run the macro.
    It is throwing the error like "Run time error 1004. 'SaveAs' of object '_workbook' failed"
    I have a save as method written inside the macro, may be due to this method it is throwing error. Please help in resolving this.

    Thank you

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,105

    Re: Not able to execute the macro when macro is password protected

    You can unprotect it and then protect it again within same code.

    Sub your_macro()
    
    'your code here
        ActiveSheet.unprotect "password" 
        ActiveWorkbook.unprotect "password" 
    'your code here
        ActiveSheet.protect "password", DrawingObjects:=True, Contents:=True, Scenarios:=True 
        ActiveWorkbook.protect "password", Structure:=True, Windows:=False 
    
    End Sub
    Last edited by zbor; 12-17-2013 at 04:00 AM.
    Never use Merged Cells in Excel

+ 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. Protected Sheet Allows Macro to Execute
    By theSizz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-27-2010, 02:17 PM
  2. How to execute a macro in a protected worksheet?
    By Ha Noi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2006, 01:05 PM
  3. [SOLVED] Require a password to execute a macro
    By Rjeffay in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-21-2006, 01:45 PM
  4. Replies: 5
    Last Post: 10-27-2005, 05:05 AM
  5. Require password to execute macro
    By richinlaf31 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-03-2005, 04: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