Closed ThunderFrame closed 8 years ago
SolidWorks 2006-2007 uses VBA 6.3, but so does Excel XP/2002 (and that works just fine with Rubberduck).
I do have to configure Solidworks to Run as Administrator, in order for it to run under Windows 10.
hmm, Access Violation seems to occur when assigning the button images/masks:
If I step over the assignments, Rubberduck loads without error.
public static void SetButtonImage(CommandBarButton button, Image image, Image mask)
{
button.FaceId = 0;
if (image == null || mask == null)
{
return;
}
try
{
//BOTH OF THESE ASSIGNMENTS CAUSE ACCESS VIOLATIONS
button.Picture = AxHostConverter.ImageToPictureDisp(image);
button.Mask = AxHostConverter.ImageToPictureDisp(mask);
}
catch (COMException exception)
{
Logger.Debug("Button image could not be set for button [" + button.Caption + "]\n" + exception);
}
}
I found a couple of KB articles: 286460 - How To Set the Mask and Picture Properties for Office XP CommandBars
The Mask and Picture properties are defined as type IPictureDisp, which is a member of the Stdole library. IPictureDisp uses methods that cannot be marshalled across process boundaries. Therefore, the Mask and Picture properties can only be called in-process (VBA macros, Automation Add-ins, and ActiveX DLLs run in-process).
As previously stated, the IPictureDisp interface cannot be marshalled across process boundaries. Attempts to set the Picture and Mask properties out-of-process result in the following error:
Run-time error '-2147418113(8000ffff)': Method 'Picture' of object '_CommandBarButton' failed
Therefore, you cannot set these properties for a CommandBarButton from any out-of-process Automation client or from an in-process component that is running in debug mode in the Visual Basic IDE. If you run the sample Add-in described in this article from the Visual Basic IDE, you will receive this error. To avoid the error while debugging, you can comment the lines that set the Picture and Mask properties or use conditional compilation, such as an #If...Then...#Else directive.
288771 - How To Create a Transparent Picture For Office CommandBar Buttons
Office XP offers a new Picture and Mask property for CommandBarButtons. This allows in-process clients (such as macro code or a COM Add-In) to directly assign a StdPicture object to the button without using the clipboard. However, due to limitations outside of Office, this technique does not work for out-of-process Automation clients, nor does it work for clients that need to remain compatible with earlier versions of Office.
Is this fixed with #2196 ?
If the diagnosis was correct (which I don't doubt), it should be.
When opening the VBE in SolidWorks 2006-2007, I get an Access Violation:
VS Output: