Share via

Need help referencing stdole.dll

Anonymous
2012-04-19T15:47:33+00:00

I’m working on template in Office 2007 and using Microsoft Visual Basic Editor. I started out by copying and modifying another template that was probably created with Office 2003 or before.  I am trying to work with the Fluent Ribbon to add new tab to template and was successful doing that.  Where I run into problem is when I try to put my own image on a button. I use the customUI.xml file to add the tab and in the file I have the child node:

<button id="Button2" label="My Normal Button"  image=”C:\myImage.jpg”  size="normal" onAction="Common.MyMacro" />

I found the below code to get the image:

Friend Class PictureConverter

Inherits AxHost

  Private Sub New()

    MyBase.New(String.Empty)

  End Sub

  Public Shared Function ImageToPictureDisp( _

    ByVal image As Image) As stdole.IPictureDisp

    Return CType(GetIPictureDispFromPicture(image), _

      stdole.IPictureDisp)

  End Function

  Public Shared Function IconToPictureDisp( _

    ByVal icon As Icon) As stdole.IPictureDisp

    Return ImageToPictureDisp(icon.ToBitmap())

  End Function

  Public Shared Function PictureDispToImage( _

    ByVal picture As stdole.IPictureDisp) As Image

    Return GetPictureFromIPicture(picture)

  End Function

End Class

Public Function GetImage( _

  ByVal imageName As String) As stdole.IPictureDisp

  Return PictureConverter.IconToPictureDisp(My.Resources.MyIcon)

End Function

My problem is that I can’t get my project to recognize stdole.dll and I don’t know where to add it to the project. I am on a computer at work so I can’t install anything but it does have Visual Studio 5 installed and using Windows Explorer I can go to the C:\WINNT\assembly dir and see the stdole.dll (version 7.0.3300)file in the Global Assembly Cache. So I read that if the project was created with Visual Studio the project should automatically get the reference to the stdole.dll. How can I get my project that was created with Visual Basic editor to reference the stdole.dll?

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

10 answers

Sort by: Most helpful
  1. Anonymous
    2012-04-19T22:00:00+00:00

    OK I am basically a Java developer and have only been fooling with templates for a couple of months so I did not even know the difference between VB.NET and VBA code. I will try to figure out how to convert the code when i go into work tomorrow.

    0 comments No comments
  2. Anonymous
    2012-04-19T21:47:24+00:00

    Hi Gary,

    When I was doing this with VBA the first thing I did was convert my jpg images to bmp. That's the only format the ribbon is going to take and I didn't want to fool around with picture converter stuff. The images need to be either 16 or 32 bit bmps.

    In the XML I defined a loadImage parameter and placed it here:

    <customUI loadImage="GetItemIcon" xmlns="http://schemas.microsoft.com/office/2006/01/customui">

    And then on any given button the XML looked like this:

    <button id="ClkAbout" image="About.bmp" size="large" onAction="ClkItemIcon" />

    The loadImage routine looked like this:

    Sub GetItemIcon(imageID, ByRef image)

            Set image = stdole.StdFunctions.LoadPicture(strPathName & imageID)

    End Sub

    I didn't do anything special to load stdole dlls.

    Hope this helps

    0 comments No comments
  3. Anonymous
    2012-04-19T18:59:39+00:00

    I assume that you have converted the VB.NET code to VBA - if so, it would be easier to see what is going on if you could post that code, with info. about what is not compiling. (I will guess that it's to do with the fact that the "objects" in stdole are actually classes).

    I have to go right now, but wondered if you might find the following article useful (it seems to be in roughly the right subject area):

    http://msdn.microsoft.com/en-us/library/aa155612(office.10).aspx

    0 comments No comments
  4. Anonymous
    2012-04-19T18:06:17+00:00

    I was able to bring in stdole2.tlb through the browse button but the code still does not compile

    0 comments No comments
  5. Anonymous
    2012-04-19T17:01:50+00:00

    In the VB editor, if you look at View->Object browser and use the drop down at the top left of the dialog box to show the libraries, I think you should see stdole because I'm pretty sure it is included by default. But if not, look at Tools->References. Normally I would expect to see "OLE Automation" checked in there - that points to (say) c:\Windows\system32\stdole2.tlb , which I think is probably the file you need for VBA. If not look down the list for OLE Automation, or see if you can find the .tlb using the Browse... button in that dialog.

    0 comments No comments