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

How to assign icon to a button in Outlook Add-in



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 23rd 09, 08:08 AM posted to microsoft.public.outlook.program_vba
paresh
external usenet poster
 
Posts: 66
Default How to assign icon to a button in Outlook Add-in

Hi,

I have wrtten Outlook COM Add-in. The attached code on startup creates the
button on outlook tool bar and assign the icon C:\local\cat.bmp. Could anyone
please tell me how could I make my Add-in independent of C:\local\cat.bmp? I
mean can I put picture somewhere in add-in itself so that while installing on
other machine it should have any problem if C:\local\cat.bmp is not there. OR
How could I use any system icon?

Set moCBMeow =
moApp.ActiveExplorer.CommandBars.Item("Standard"). FindControl(, , "890",
False, True)
If TypeName(moCBMeow) = "Nothing" Then
Set moCBMeow =
moApp.ActiveExplorer.CommandBars.Item("Standard"). Controls.Add(msoControlButton, , "890", , True)
End If
With moCBMeow
.BeginGroup = True
.Caption = "Copylink"
.DescriptionText = "Meow meow meow"
.Enabled = True
.OnAction = "!CopyLinkTestingAddin.Connect"
Clipboard.Clear
Clipboard.SetData LoadPicture("c:\local\cat.bmp")
.PasteFace
.Style = msoButtonIconAndCaption
.Tag = "890"
.ToolTipText = "Meow meow meow"
.Visible = True
End With


Thanks.
Paresh
Ads
  #2  
Old March 23rd 09, 01:18 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default How to assign icon to a button in Outlook Add-in

Any image supplied for a CommandBarButton object must be 16x16x256 colors.
If put on the clipboard it must be a BMP, if you use Picture/Mask you supply
an IPictureDisp object.

To re-use an Outlook button image you get the CommandBarButton with the
image you want and use CopyFace to put it on the clipboard for PasteFace to
grab.

For any other image you can put it in the resource file for your addin
project and grab it from there, using whatever method is available in the
language you are using for loading image resources.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"paresh" wrote in message
...
Hi,

I have wrtten Outlook COM Add-in. The attached code on startup creates the
button on outlook tool bar and assign the icon C:\local\cat.bmp. Could
anyone
please tell me how could I make my Add-in independent of C:\local\cat.bmp?
I
mean can I put picture somewhere in add-in itself so that while installing
on
other machine it should have any problem if C:\local\cat.bmp is not there.
OR
How could I use any system icon?

Set moCBMeow =
moApp.ActiveExplorer.CommandBars.Item("Standard"). FindControl(, , "890",
False, True)
If TypeName(moCBMeow) = "Nothing" Then
Set moCBMeow =
moApp.ActiveExplorer.CommandBars.Item("Standard"). Controls.Add(msoControlButton,
, "890", , True)
End If
With moCBMeow
.BeginGroup = True
.Caption = "Copylink"
.DescriptionText = "Meow meow meow"
.Enabled = True
.OnAction = "!CopyLinkTestingAddin.Connect"
Clipboard.Clear
Clipboard.SetData LoadPicture("c:\local\cat.bmp")
.PasteFace
.Style = msoButtonIconAndCaption
.Tag = "890"
.ToolTipText = "Meow meow meow"
.Visible = True
End With


Thanks.
Paresh


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Outlook 2003 - custom forms - task assign button dissappears formation Outlook - Using Forms 3 February 20th 09 03:24 PM
Adding an icon to outlook commandbar button Exchnerd Add-ins for Outlook 1 November 6th 08 09:28 PM
Custom Task Form - Assign Button steve Outlook - Using Forms 1 July 8th 07 07:36 PM
assign macro to custom toolbar button Rod Nolan Outlook and VBA 1 September 7th 06 05:34 AM
Simple assign category button caero Outlook and VBA 15 March 14th 06 03:35 PM


All times are GMT +1. The time now is 06:13 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-2025 Outlook Banter.
The comments are property of their posters.