rory.ap
rory.ap

Reputation: 35318

Intellisense in private modules

Assume I have a module named Module1 with the following code:

Private Sub MyPrivateSub()
    'do something
End Sub

Public Sub MyPublicSub()
    'do something
End Sub

Public Sub test()

End Sub

If I place the cursor inside Test() and start typing "MyPrivateSub" or "MyPublicSub", I don't get any intellisense. I can type "Module1." (or "Me." if Module1 were a class module) to get an intellisense menu, but this only contains the public method MyPublicSub, as shown here:

enter image description here

Is there some way to get an intellisense menu for all members, public and private? I'm working on a project with modules that have many methods, and going up and down continually to copy/paste member names is time consuming.

Upvotes: 2

Views: 631

Answers (2)

user2140173
user2140173

Reputation:

Short answer

hit a combination of

CTRL+SPACE

and start typing the sub name like shown here

enter image description here

Long answer

Everything you do in programming matters. When you decide to make your sub/function/variable private you do that for a reason and you need to understand how this will affect the access level and "scope".

The scope of a member is dictated by its access level and in VBE anything that is private and qualified with it's parent member does not get intelli-sense. Simply, because you can't (are not supposed to be able to access it) from the outside.

Because your MyPrivateSub access level is Private you can't access it with intelli-sense through qualifying the module with Module1..

Upvotes: 4

Alex
Alex

Reputation: 1642

If you're starting from fresh, you can do the following: for all your private sub function, name them into a standard format but as public function at the moment, for e.g.:

Public sub iamprivate_calDate ()
Public sub iamprivate_getsetfunction()
...

after you're completed with your macros, simply find and replace all your "Public sub iamprivate" into "Private sub " in your editor.

Upvotes: 0

Related Questions