+ Reply to Thread
Results 1 to 7 of 7

Bypassing protection for macros applied to an image

  1. #1
    Registered User
    Join Date
    08-13-2006
    Posts
    5

    Bypassing protection for macros applied to an image

    G'day guys,

    I have an excel worksheet with protection to mainly hide formulas and prevent users from accidentally deleting/modifying the formulas.

    I have created a couple of macro's to reset a filter on a collum and reset the wrap text function on the sheet, however, when I go to execute the macro the sheet come up with an error due to it being protected.

    Does anyone know how I can keep the sheet protected (or at least the formulas hidden) and still have the Macros?

    Any help would be appreciated.

    Cheers
    Damian

  2. #2
    NickHK
    Guest

    Re: Bypassing protection for macros applied to an image

    You have a couple of options:
    - Wrap you code in WS.Unprotect/.Protect statements
    - Check out the 5th argument to .Protect .

    NickHK

    "damiand_1982" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > G'day guys,
    >
    > I have an excel worksheet with protection to mainly hide formulas and
    > prevent users from accidentally deleting/modifying the formulas.
    >
    > I have created a couple of macro's to reset a filter on a collum and
    > reset the wrap text function on the sheet, however, when I go to
    > execute the macro the sheet come up with an error due to it being
    > protected.
    >
    > Does anyone know how I can keep the sheet protected (or at least the
    > formulas hidden) and still have the Macros?
    >
    > Any help would be appreciated.
    >
    > Cheers
    > Damian
    >
    >
    > --
    > damiand_1982
    > ------------------------------------------------------------------------
    > damiand_1982's Profile:

    http://www.excelforum.com/member.php...o&userid=37461
    > View this thread: http://www.excelforum.com/showthread...hreadid=571224
    >




  3. #3
    Registered User
    Join Date
    08-13-2006
    Posts
    5

    reply to nick

    hi nick,

    hanks for your quick reply. I created the macro using the record macro function in excel. To Wrap the code in WS.Unprotect/.Protect statements, will I need to Alt F11 and go to the VBA script for that macro?

    Cheers
    Damian

  4. #4
    NickHK
    Guest

    Re: Bypassing protection for macros applied to an image

    Yes, as you will need to edit the original code.

    Nick

    "damiand_1982" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > hi nick,
    >
    > hanks for your quick reply. I created the macro using the record macro
    > function in excel. To Wrap the code in WS.Unprotect/.Protect
    > statements, will I need to Alt F11 and go to the VBA script for that
    > macro?
    >
    > Cheers
    > Damian
    >
    >
    > --
    > damiand_1982
    > ------------------------------------------------------------------------
    > damiand_1982's Profile:

    http://www.excelforum.com/member.php...o&userid=37461
    > View this thread: http://www.excelforum.com/showthread...hreadid=571224
    >




  5. #5
    Registered User
    Join Date
    08-13-2006
    Posts
    5

    Macro Code

    Hi Nick,

    I am an excel novice (especially when it comes to VBA script). Could you look at the code below and give me some advice on where the protect/unprotect script should be placed?

    Sub RefreshScreen()
    '
    ' RefreshScreen Macro
    ' Macro recorded 15/08/2006 by Damian Dancer
    '
    ' Keyboard Shortcut: Ctrl+r
    '
    Selection.AutoFilter Field:=5
    Cells.Select
    Cells.EntireRow.AutoFit
    Selection.AutoFilter Field:=5, Criteria1:="Blown Bulbs"
    Range("A1").Select
    End Sub


    Your helps appreciated

  6. #6
    Gord Dibben
    Guest

    Re: Bypassing protection for macros applied to an image

    Not Nick but will try to help.

    Sub RefreshScreen()
    '
    ' RefreshScreen Macro
    ' Macro recorded 15/08/2006 by Damian Dancer
    '
    ' Keyboard Shortcut: Ctrl+r
    '
    ActiveSheet.Unprotect Password:="justme"
    Selection.AutoFilter Field:=5
    Cells.Select
    Cells.EntireRow.AutoFit
    Selection.AutoFilter Field:=5, Criteria1:="Blown Bulbs"
    'more code here to deal with "Blown Bulbs"?
    Range("A1").Select
    'Selection.AutoFilter to turn off Filter?
    ActiveSheet.Protect Password:="justme", DrawingObjects:=True, _
    Contents:=True, Scenarios:=True
    End Sub


    Gord Dibben MS Excel MVP

    On Mon, 14 Aug 2006 19:20:05 -0400, damiand_1982
    <[email protected]> wrote:

    >
    >Hi Nick,
    >
    >I am an excel novice (especially when it comes to VBA script). Could
    >you look at the code below and give me some advice on where the
    >protect/unprotect script should be placed?
    >
    >Sub RefreshScreen()
    >'
    >' RefreshScreen Macro
    >' Macro recorded 15/08/2006 by Damian Dancer
    >'
    >' Keyboard Shortcut: Ctrl+r
    >'
    >Selection.AutoFilter Field:=5
    >Cells.Select
    >Cells.EntireRow.AutoFit
    >Selection.AutoFilter Field:=5, Criteria1:="Blown Bulbs"
    >Range("A1").Select
    >End Sub
    >
    >Your helps appreciated



  7. #7
    Registered User
    Join Date
    08-13-2006
    Posts
    5

    Re: Bypassing protection for macros applied to an image

    Thanks Gord,

    It looks like everything's worked except I need the protection (when re-enabled by the macro) to still allow the use of autofilters. I have them setup at the header row. Can you advise whether this can be coded?

    Also in the macro coding you have the questions:

    'more code here to deal with "Blown Bulbs"? and
    'Selection.AutoFilter to turn off Filter?

    What does this mean?

    Sorry mate. This is all a big learning process for me. I really appreciate your help and advice.

    Cheers
    Damian

+ 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