+ Reply to Thread
Results 1 to 6 of 6

Create private macro/function

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-20-2005
    Posts
    256
    Quote Originally Posted by vbace2
    Thanks Desert Piranha. This works for what I was trying to do.

    However, here is another question along the same line.

    Can I create a macro that doesn't show up in the macro list, but it still has a shortcut to run? Basically, I want to be able to run a macro using a shortcut key, but I don't want the users to know about it.
    Hi vbace,

    I don't know how to get a keyboard shortcut to work on the private Module.
    The Code will run if called from another macro, or a button etc.

    Myself, i use a "Right Click Menu" to run the code. I have several generic Right Click Menus in a Add-In, which i can use. That way they don't go with the Workbook.

    I'm sure someone else has a better way.
    Last edited by Desert Piranha; 11-10-2006 at 10:59 PM.
    Thx
    Dave
    "The game is afoot Watson"

  2. #2
    Registered User
    Join Date
    09-11-2006
    Posts
    56

    hidden macros

    Hi guys,
    I was able to sort of hide the macro, I would imagine it would depend on how much time your users have on their hands as to whether they could figure it out.

    in a module I named Mod_private I added this code:

    Option Private Module
    Sub test_macro()
    Dim Msg, Style, Title, Help, Ctxt, Response, MyString
    Msg = "Do you want to continue ?" ' Define message.
    Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
    Title = "MsgBox Demonstration" ' Define title.
    Help = "DEMO.HLP" ' Define Help file.
    Ctxt = 1000 ' Define topic
    ' context.
    ' Display message.
    Response = MsgBox(Msg, Style, Title, Help, Ctxt)
    If Response = vbYes Then ' User chose Yes.
    MyString = "Yes" ' Perform some action.
    Else ' User chose No.
    MyString = "No" ' Perform some action.
    End If
    End Sub
    in a module I named Mod_open I added this code:

    Sub Macro1()
    '
    ' Macro1 Macro
    '
    '
    ' Keyboard Shortcut: Ctrl+m
    '
    Call test_macro
    End Sub

    in the Macros dialog box the macro Macro1() is visible
    the Macro Test_macro() is not visible, running macro1() will call and run Text_macro(), I am not sure this is what your looking for .. but it was an interesting excercise in subtrafuge.

+ 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