How to programmatically change caption of macro custom button on Outlook command toolbar with VBA?

  • Thread starter Thread starter rj
  • Start date Start date
R

rj

Outlook 2002 on Home XP sp2

I'm a newbie with VBA programming and the Outlook Object structure etc.

I used Tools/Customize/Commands/Macros to select a macro
(Project1.ThisOutlookSession.MyFormMarcro) I'd written to create a Custom
Button on the Outlook command toolbar to execute the macro when the button
is clicked.

The macro brings up a User Form where I enter some info. Depending on what
I enter I'd like to change the macro button caption when I close the form.

My question is can I programmatically change the macro button caption with
VBA? How do I do it?

Also, the macro button data is persistent so where is it stored? (registry,
an Outlook or Office data file?). I'd like to backup this data also when I
do my regular backup of my outlook.pst file and MS Office documents.

thanks
rj
 
You can get a reference to your custom button by name, depending on which
command bar you've stored it on:

Dim objStandardBar As Office.CommandBar
Dim objMyButton As Office.CommandBarButton

Set objStandardBar = ActiveExplorer.CommandBars("Standard")
Set objMyButton = objStandardBar.Controls("MyButton")
objMyButton.Caption = "My New Caption"

Custom toolbar data is stored in the "C:\Documents and
Settings\[USERNAME]\Application Data\Microsoft\Outlook\outcmd.dat" file. The
best way to preserve this and other data is to run the Office Save My
Settings Wizard (in the Microsoft Office Tools program group).
 
Thats perfect, thanks! I didn't realize I had to use the ActiveExplorer
Object for Outlook. Thanks for the outcmd.dat and Save My Settings info.
Thanks
rj
 
Back
Top