Is there a way to get full IntelliSense for VBA in

2020-02-23 04:04发布

问题:

In VB.NET, the IntelliSense pops up as soon as you start typing which gives you a pretty full list of things you can use at that moment. The IntelliSense in VBA however, doesn't kick on for me until a period is put after the part you're using. For example, I go into the VBA editor in Excel 2007 and start typing the word "Range" but the IntelliSense doesn't come up until I type "Range." after which it will give me a list of things I can use at that point.

Is there any way to make IntelliSense come up sooner in the VBA editor, so that I'm able to see a list of things that can be used like Davg, DCount, etc?

回答1:

No, but you can type Excel first. Put a period after that, and you'll find out more than you ever wanted to know about Excel.

Same with Access. Type Access and a period, and you will find DCount there.



回答2:

Just press Ctrl + Space at any time in the editor.



回答3:

Unfortunately in Excel some objects are declared 'As Object' and Object doesn't have any methods so Intellisense won't be able to display any. The main culprit being Excel.ActiveSheet.

If you know what the type actually is then you can declare it explicitly and assign it to the value you want. EG:

Dim mySheet As Worksheet
Set mySheet = ActiveSheet     'This line would cause a type mismatch error if mySheet was declared as something other than a WorkSheet
mysheet.[All The Intellisense For a Worksheet Pops Up]


回答4:

VBA is a different beast than .NET so I'm not sure how to bring up the IntelliSense quicker. I find I have the same problem you're having in 2003.

I would suggest checking out the Object Browser though. In 2003, it's View > Object Browser, or F2, in the VB Editor. I find it's a great way to explore the class libraries available. It will show you everything that you currently have referenced and once you reference more libraries, they will also show up in the Object Browser.