+ Reply to Thread
Results 1 to 2 of 2

Unprotect - execute macro - protect

  1. #1
    Registered User
    Join Date
    03-11-2014
    Location
    Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    37

    Unprotect - execute macro - protect

    Hi all
    I've been searching for code to unprotect my workbook, run the code and then reprotect it. I have found simple solutions like

    ThisWorkbook.Unprotect Password:="accounts_2014"

    My Code

    ThisWorkbook.Protect Password:="accounts_2014"


    But somehow it does not work and provides a runtime error.
    Can anyone help?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,621

    Re: Unprotect - execute macro - protect

    It may be that you need to protect the worksheet(s) rather than the workbook.

    I suggest you post a sample workbook with the code.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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. [SOLVED] Macro to Unprotect and Protect
    By MBeedle in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-22-2013, 01:32 AM
  2. [SOLVED] Protect / Unprotect Macro
    By jason.hampton in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-18-2012, 11:53 AM
  3. unprotect and protect macro
    By stevekirk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-26-2007, 05:32 AM
  4. Macro to Protect and UnProtect
    By mmacw in forum Excel General
    Replies: 2
    Last Post: 02-13-2007, 04:39 PM
  5. [SOLVED] unprotect and protect within a macro
    By Staalkop in forum Excel General
    Replies: 4
    Last Post: 10-27-2005, 04:05 PM

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