Qualifying Commandbars - Excel 2000

V

Victor

I ran the following code under Sheet1, ThisWorkbook and Module1 with no
problem:

Public Sub ShowBarNames()

Dim bar as CommandBar

For Each bar in Application.CommandBars
Debug.Print bar.Name
Next

End Sub

Now, I get an error when the code is inside ThisWorkbook and
CommandBars is not fully qualified, i.e.:

Public Sub ShowBarNames()

Dim bar as CommandBar

For Each bar in CommandBars
Debug.Print bar.Name
Next

End Sub

How come? Isn't Commandbars a global object under Application?
 
T

Tom Ogilvy

the unqualfied object in Thisworkbook becomes

Thisworkbook.CommandBars

which raises the error.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top