Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Dec 2007
    Posts
    179
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hi all,

    Can you make a subroutine/function as Private in module but also visible from all other modules?

    TIA

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Quote Originally Posted by amakeler View Post
    Can you make a subroutine/function as Private in module but also visible from all other modules?
    Actually, the meaning of Private is invisible outside the module, so no. You can't have it both Private and Public.

    You still may be able to call a Private Sub or Function from another module by qualifying it with the module name; I haven't tested that recently.

    Are you trying hide a Sub from the Macros dialog? Anything that takes arguments, even if declared as Public, will not appear in the Macros list. The arguments don't have to be real, either. For example:

    Code:
    Sub SomeProcedure(Optional strWhatever As String = vbNullString)
    MsgBox "I'm not a macro! strWhatever = '" & strWhatever & "'"
    End Sub
    Does this help?

  3. #3
    2 Star Lounger
    Join Date
    Dec 2007
    Posts
    179
    Thanks
    3
    Thanked 0 Times in 0 Posts
    >> You still may be able to call a Private Sub or Function from another module by qualifying it with the module name; I haven't tested that recently.

    Tried it. Didn't work.

    >> Are you trying hide a Sub from the Macros dialog?

    Y - e - e - s - s - s - s

    >> Anything that takes arguments, even if declared as Public, will not appear in the Macros list. The arguments don't have to be real, either.

    Long time since a piece of code made me smile. Beautiful idea! Sweet and simple!

    TNX!

    - avi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •