Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   How to add an Icon to a commandBarButton (http://www.outlookbanter.com/outlook-vba/9817-how-add-icon-commandbarbutton.html)

David March 29th 06 03:39 PM

How to add an Icon to a commandBarButton
 
Hi,

I try To add an Icon(custom icon) to a commandBarButton.
I wrote the foloeing code in vba:

Dim myOlApp As New Outlook.Application
Dim objInsp As Outlook.Inspector
Dim objCBB As Office.CommandBarButton
Dim objCB As Office.CommandBar

Set myOlApp = CreateObject("Outlook.Application")
Set objInsp = myOlApp.ActiveInspector
Set objCB = objInsp.CommandBars("standard")
Set objCBB = objCB.Controls.Add(Type:=msoControlButton)
With objCBB
.Style = msoButtonIconAndCaption
.Caption = "MyAction"
.Visible = True
.Picture = stdole.LoadPicture("C:\Documents and Settings\MrkvLogo.ico")
.Mask = stdole.LoadPicture("C:\Documents and Settings\MrkvMask.ico")


End With

I get this error in ".Picture=..." and ".Mask=..." rows
Error message:
Run time error '5' :
Invalid procedure call or argument.

I use outlook 2003. However I need this code to work also with outlook 2000.


Thanks,
David

Dmitry Streblechenko March 29th 06 06:39 PM

How to add an Icon to a commandBarButton
 
1. Use "set" when setting the Picture and Mask properties.
2. Picture and Mask properties were added in Outlook 2002, in Outlook 2000
you can only use CommandBarButton.PasteFace method to paste a bitmap
previously copied to the clipboard.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"David" wrote in message
. ..
Hi,

I try To add an Icon(custom icon) to a commandBarButton.
I wrote the foloeing code in vba:

Dim myOlApp As New Outlook.Application
Dim objInsp As Outlook.Inspector
Dim objCBB As Office.CommandBarButton
Dim objCB As Office.CommandBar

Set myOlApp = CreateObject("Outlook.Application")
Set objInsp = myOlApp.ActiveInspector
Set objCB = objInsp.CommandBars("standard")
Set objCBB = objCB.Controls.Add(Type:=msoControlButton)
With objCBB
.Style = msoButtonIconAndCaption
.Caption = "MyAction"
.Visible = True
.Picture = stdole.LoadPicture("C:\Documents and Settings\MrkvLogo.ico")
.Mask = stdole.LoadPicture("C:\Documents and
Settings\MrkvMask.ico")


End With

I get this error in ".Picture=..." and ".Mask=..." rows
Error message:
Run time error '5' :
Invalid procedure call or argument.

I use outlook 2003. However I need this code to work also with outlook
2000.


Thanks,
David





All times are GMT +1. The time now is 08:56 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com