C
C. Johnson
Hello,
I am using VB 6.0 SP6 (Add-In designer) with Office 2003 (SP1). I am trying
to create a toolbar in a COM add-in. In the AddinInstance_OnConnection
function, I call a function to draw my toolbar. When I attempt to add a
picture and mask to the CommandBarButton, I get the following error message:
-2147418113 Automation Error Catastrophic Failure.
I set a watch on the CommandBarButton while I was creating it, and the
..Picture and .Mask attributes have <Automation Error> listed as their value.
Here is my code:
Dim cb As Office.CommandBar
Set cb = mPPTApp.CommandBars.Add(Name:="MyTest", Position:=msoBarFloating,
Temporary:=False)
Dim picPicture As stdole.IPictureDisp
Dim picMask As stdole.IPictureDisp
Dim obutton As Office.CommandBarButton
Set obutton = cb.Controls.Add(Type:=msoControlButton)
'set a watch on obutton here and .Picture and .Mask values = <Automation
Error>
Set picPicture = stdole.StdFunctions.LoadPicture("C:\Test\Images\Img1.bmp")
Set picMask = stdole.StdFunctions.LoadPicture("C:\Test\Images\Img1Mask.bmp")
On Error GoTo ErrorHandler
With obutton
.ToolTipText = "Button 1"
.Caption = "Button 1"
.OnAction = "Button1_Click"
.Style = msoButtonIcon
'goes to error handler when the next statement is executed
.Picture = picPicture
.Mask = picMask
End With
This code was copied from a VBA macro add-in that we have decided to convert
to a COM add-in, and it worked there.
Any help would be appreciated.
Thanks,
David
I am using VB 6.0 SP6 (Add-In designer) with Office 2003 (SP1). I am trying
to create a toolbar in a COM add-in. In the AddinInstance_OnConnection
function, I call a function to draw my toolbar. When I attempt to add a
picture and mask to the CommandBarButton, I get the following error message:
-2147418113 Automation Error Catastrophic Failure.
I set a watch on the CommandBarButton while I was creating it, and the
..Picture and .Mask attributes have <Automation Error> listed as their value.
Here is my code:
Dim cb As Office.CommandBar
Set cb = mPPTApp.CommandBars.Add(Name:="MyTest", Position:=msoBarFloating,
Temporary:=False)
Dim picPicture As stdole.IPictureDisp
Dim picMask As stdole.IPictureDisp
Dim obutton As Office.CommandBarButton
Set obutton = cb.Controls.Add(Type:=msoControlButton)
'set a watch on obutton here and .Picture and .Mask values = <Automation
Error>
Set picPicture = stdole.StdFunctions.LoadPicture("C:\Test\Images\Img1.bmp")
Set picMask = stdole.StdFunctions.LoadPicture("C:\Test\Images\Img1Mask.bmp")
On Error GoTo ErrorHandler
With obutton
.ToolTipText = "Button 1"
.Caption = "Button 1"
.OnAction = "Button1_Click"
.Style = msoButtonIcon
'goes to error handler when the next statement is executed
.Picture = picPicture
.Mask = picMask
End With
This code was copied from a VBA macro add-in that we have decided to convert
to a COM add-in, and it worked there.
Any help would be appreciated.
Thanks,
David