+ Reply to Thread
Results 1 to 6 of 6

Protect a Macro

  1. #1
    Darin Kramer
    Guest

    Protect a Macro



    Howdie All,

    I have a workbook with many macros in, some I use for design, and would
    not like users to be able to run them, (which they can currently easily
    do by selecting Tools...macro...run...)

    So the question is, can I protect some macros from being run?

    Regards

    D

    *** Sent via Developersdex http://www.developersdex.com ***

  2. #2
    Forum Contributor
    Join Date
    12-04-2003
    Location
    Burrton, Kansas USA
    MS-Off Ver
    2003
    Posts
    162
    Darin:
    This will prevent the user from accessing the macro from the Tools menu.

    Sub macro1(Optional HideRoutine As Integer)

    Brian M.

  3. #3
    Zone
    Guest

    Re: Protect a Macro

    You can use the Private keyword with your macro to prevent it from
    showing in the list of macros, such as

    Private Sub Macro1()


  4. #4
    Chip Pearson
    Guest

    Re: Protect a Macro

    If you put

    Option Private Module

    as the first line of code in your code module, none of the macros
    in that module will be listed in the Macro Dialog. If, however,
    the user knows the name of the macro, he can type it in the
    dialog and get it to run.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "Darin Kramer" <darin_kramer@hotmail.com> wrote in message
    news:OsLIAo3cGHA.3908@TK2MSFTNGP04.phx.gbl...
    >
    >
    > Howdie All,
    >
    > I have a workbook with many macros in, some I use for design,
    > and would
    > not like users to be able to run them, (which they can
    > currently easily
    > do by selecting Tools...macro...run...)
    >
    > So the question is, can I protect some macros from being run?
    >
    > Regards
    >
    > D
    >
    > *** Sent via Developersdex http://www.developersdex.com ***




  5. #5
    Ivan Raiminius
    Guest

    Re: Protect a Macro

    Hi Darin,

    you can also use useless optional parameter:

    Sub macro1(optional useless as variant)

    macro1 will not be visible to the user in macro>run, but you will not
    have any problems in your code with this useless parameter (maybe you
    could have problems with making the sub private).

    Regards,
    Ivan


  6. #6
    Darin Kramer
    Guest

    Re: Protect a Macro

    Thanks all for your feedback!!

    Regards

    Darin



    *** Sent via Developersdex http://www.developersdex.com ***

+ 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