+ Reply to Thread
Results 1 to 3 of 3

Commandbutton picture problem

  1. #1
    Jim B
    Guest

    Commandbutton picture problem

    Hi,

    I'm trying to set the picture of a commandbutton with VBA code in Excel and
    I get an automation error:

    -2147467259 (80004005)

    Here's the code I'm using:

    Dim cbDA As CommandBar
    Dim cbtDA As CommandBarButton
    Dim picPicture As IPictureDisp
    Dim picMask As IPictureDisp

    Set cbDA = Application.CommandBars("Data Analysis")

    Set cbtDA = cbDA.Controls.Add(msoControlButton)
    Set picPicture = stdole.StdFunctions.LoadPicture( _
    "c:\corp_dev\Icon_Lib\eWorld 2000 Win\globe.ico")
    With cbtDA
    .Style = msoButtonIconAndCaption
    .TooltipText = "Listing of available reports."
    .Caption = "Reports"
    .Visible = True
    .Picture = picPicture
    End With

    I made sure the globe.ico file was correctly referenced and that stdole was
    available. I even tried testing it with a common bmp file used by office
    and it still failed.

    What am I doing wrong?

    Thanks,

    --
    Jim Bourque

  2. #2
    RC-
    Guest

    Re: Commandbutton picture problem

    Jim,
    Is there a particular reason why you want to load your own picture, i.e.
    does the corporate office force you to use a certain icon? If not, check
    this utility out, I have been using it for about three years now and I swear
    by it.

    http://skp.mvps.org/faceid.htm

    Once you load the add-in, all you have to do is browse for an icon that you
    like and plug in the number into the .FaceID property of your menu bar

    Example:

    With cbtDA
    .Style = msoButtonIconAndCaption
    .TooltipText = "Listing of available reports."
    .Caption = "Reports"
    .Visible = True
    .Picture = picPicture YOU WOULD REMOVE THIS ENTRY AND REPLACE
    WITH THE ONE BELOW
    .FaceID = 2487 THE NUMBER WOULD BE THE NUMBER THAT IS
    ASSOCIATED WITH THE ICON YOU LIKE
    End With


    Sorry for the caps above, just wanted to make sure you saw the instructions

    I hope this helps
    RC-


    "Jim B" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I'm trying to set the picture of a commandbutton with VBA code in Excel
    > and
    > I get an automation error:
    >
    > -2147467259 (80004005)
    >
    > Here's the code I'm using:
    >
    > Dim cbDA As CommandBar
    > Dim cbtDA As CommandBarButton
    > Dim picPicture As IPictureDisp
    > Dim picMask As IPictureDisp
    >
    > Set cbDA = Application.CommandBars("Data Analysis")
    >
    > Set cbtDA = cbDA.Controls.Add(msoControlButton)
    > Set picPicture = stdole.StdFunctions.LoadPicture( _
    > "c:\corp_dev\Icon_Lib\eWorld 2000 Win\globe.ico")
    > With cbtDA
    > .Style = msoButtonIconAndCaption
    > .TooltipText = "Listing of available reports."
    > .Caption = "Reports"
    > .Visible = True
    > .Picture = picPicture
    > End With
    >
    > I made sure the globe.ico file was correctly referenced and that stdole
    > was
    > available. I even tried testing it with a common bmp file used by office
    > and it still failed.
    >
    > What am I doing wrong?
    >
    > Thanks,
    >
    > --
    > Jim Bourque




  3. #3
    Jim B
    Guest

    Re: Commandbutton picture problem

    I wasn't being forced to use certain icons so this will work great for me.
    Thanks a lot for this!

    --
    Jim Bourque


    "RC-" wrote:

    > Jim,
    > Is there a particular reason why you want to load your own picture, i.e.
    > does the corporate office force you to use a certain icon? If not, check
    > this utility out, I have been using it for about three years now and I swear
    > by it.
    >
    > http://skp.mvps.org/faceid.htm
    >
    > Once you load the add-in, all you have to do is browse for an icon that you
    > like and plug in the number into the .FaceID property of your menu bar
    >
    > Example:
    >
    > With cbtDA
    > .Style = msoButtonIconAndCaption
    > .TooltipText = "Listing of available reports."
    > .Caption = "Reports"
    > .Visible = True
    > .Picture = picPicture YOU WOULD REMOVE THIS ENTRY AND REPLACE
    > WITH THE ONE BELOW
    > .FaceID = 2487 THE NUMBER WOULD BE THE NUMBER THAT IS
    > ASSOCIATED WITH THE ICON YOU LIKE
    > End With
    >
    >
    > Sorry for the caps above, just wanted to make sure you saw the instructions
    >
    > I hope this helps
    > RC-
    >
    >
    > "Jim B" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi,
    > >
    > > I'm trying to set the picture of a commandbutton with VBA code in Excel
    > > and
    > > I get an automation error:
    > >
    > > -2147467259 (80004005)
    > >
    > > Here's the code I'm using:
    > >
    > > Dim cbDA As CommandBar
    > > Dim cbtDA As CommandBarButton
    > > Dim picPicture As IPictureDisp
    > > Dim picMask As IPictureDisp
    > >
    > > Set cbDA = Application.CommandBars("Data Analysis")
    > >
    > > Set cbtDA = cbDA.Controls.Add(msoControlButton)
    > > Set picPicture = stdole.StdFunctions.LoadPicture( _
    > > "c:\corp_dev\Icon_Lib\eWorld 2000 Win\globe.ico")
    > > With cbtDA
    > > .Style = msoButtonIconAndCaption
    > > .TooltipText = "Listing of available reports."
    > > .Caption = "Reports"
    > > .Visible = True
    > > .Picture = picPicture
    > > End With
    > >
    > > I made sure the globe.ico file was correctly referenced and that stdole
    > > was
    > > available. I even tried testing it with a common bmp file used by office
    > > and it still failed.
    > >
    > > What am I doing wrong?
    > >
    > > Thanks,
    > >
    > > --
    > > Jim Bourque

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1