ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Qualifying Commandbars - Excel 2000 (https://www.excelbanter.com/excel-programming/353100-qualifying-commandbars-excel-2000-a.html)

Victor[_5_]

Qualifying Commandbars - Excel 2000
 
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?


Tom Ogilvy

Qualifying Commandbars - Excel 2000
 
the unqualfied object in Thisworkbook becomes

Thisworkbook.CommandBars

which raises the error.

--
Regards,
Tom Ogilvy


"Victor" wrote in message
ups.com...
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?




Victor[_5_]

Qualifying Commandbars - Excel 2000
 
I get it. Is this true for any unqualified name in ThisWorkbook?

Thanks,
Victor



All times are GMT +1. The time now is 03:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com