A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Tags: , ,

How to add an Icon to a commandBarButton





 
 
Thread Tools Display Modes
  #1  
Old March 29th 06, 02:39 PM posted to microsoft.public.outlook.program_vba
David
external usenet poster
 
Posts: 4
Default 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
Ads
  #2  
Old March 29th 06, 05:39 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 1,412
Default 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



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Out of office add-in to show icon when turned on or off Mike Matheny Add-ins for Outlook 0 February 21st 06 10:09 PM
how to add commandbarbutton to inspector window Ram Outlook and VBA 0 January 19th 06 06:07 AM
how to add commandbarbutton to inspector window Ram Outlook - General Queries 1 January 18th 06 08:42 PM
how to add commandbarbutton to inspector window Ram Add-ins for Outlook 0 January 18th 06 03:18 PM
Add empty "junk mai" folderl icon to outlook 2003 grkuntzmd Outlook - Installation 2 January 17th 06 10:19 PM


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


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2008 Outlook Banter, part of the NewsgroupBanter project.
The comments are property of their posters.
Mortgage - Loans - MPAA - US Business Directory - Pay Day Loans