ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   CommandBars (https://www.excelbanter.com/excel-programming/436203-commandbars.html)

S Shipley

CommandBars
 
MWhen I try to excute this code I get a compile error on Controls saying the
Method or data member not found. How do I declare myControl so this code
will work?

Dim myBar As CommandBars
Dim myControl As CommandBarControls

Set myBar = CommandBars("Custom")
Set myControl = myBar.Controls.Add(Type:=msoControlComboBox, ID:=1)

Thanks,
Sam

Dave Peterson

CommandBars
 
Drop the final S from both of the declarations

Dim myBar As CommandBar
Dim myControl As CommandBarControl

You want each of those variables to represent a single object of that type--not
the entire collection of those objects, right?



S Shipley wrote:

MWhen I try to excute this code I get a compile error on Controls saying the
Method or data member not found. How do I declare myControl so this code
will work?

Dim myBar As CommandBars
Dim myControl As CommandBarControls

Set myBar = CommandBars("Custom")
Set myControl = myBar.Controls.Add(Type:=msoControlComboBox, ID:=1)

Thanks,
Sam


--

Dave Peterson


All times are GMT +1. The time now is 07:07 AM.

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