win32com makepy problem

Gerrit van Dyk gerritvd at decillion.net
Tue Mar 26 04:37:36 EST 2002


Hi all,

I have the following problem using the office 9.0 object library. When I 
generate the Office 9.0 Object library using makepy the following code 
does not work, but when I use the dynamic dispatch method it does. How 
do I solve the problem using the early bound dispatch method as I need 
early binding for other features (constants etc)?

This method is defined in my server class and the self.application 
attribute points to a valid Excel.Application instance

1:def AddCustomMenu(self):
2: 
cbMenuBar = self.application.CommandBars("Worksheet Menu Bar")
3: 
muCustom = cbMenuBar.Controls.Add(Type = 10) # msoControlPopup
4:
5: 
muCustom.Caption = "Toolkit"
6:
7: 
item = muCustom.Controls.Add(Type = 1) # msoControlButton
8: 
item.Caption = "Show Data Form"


The problem is on line 7. muCustom is of type CommandBarControl in the 
early binding case. In the late(dynamic) binding case it is a 
CommandBarPopup. CommandBarControl does not have a Controls property 
where CommandBarPopup does.

How can i rectify the problem? (typecast ?) How?

Regards
Gerrit van Dyk




More information about the Python-list mailing list