Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
RC- RC- is offline
external usenet poster
 
Posts: 12
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Picture problem dwake Excel Discussion (Misc queries) 1 May 12th 10 07:40 PM
size FaceID picture on commandbutton RB Smissaert Excel Programming 2 January 7th 06 11:20 AM
Change CommandButton Picture TheVisionThing Excel Programming 0 December 14th 05 05:24 PM
Displaying a picture by pushing CommandButton Jean[_4_] Excel Programming 4 February 14th 05 11:39 AM
Enabled problem on commandbutton Swordster Excel Programming 1 May 18th 04 10:21 AM


All times are GMT +1. The time now is 10:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"