Program "Click on Ribbon Button" Using VBA

  • Thread starter Thread starter hlock
  • Start date Start date
H

hlock

I don't know if anyone can help me, but I thought I would ask. In Outlook
2007, we have a 3rd party add-in that imports an email to a document
repository. The "Save to Vignette IDM" button resides on the command bar in
explorer and in the Add-Ins menu on the ribbon. Thanks to Sue Moshier, we
are able to "click" on the button on the command bar in explorer. However,
the code only runs for the highlighted email in explorer. The problem is
when we have multiple emails up and want to import an open email that is not
selected in explorer. The code runs, but it imports the selected email in
explorer, not the active email.

I need to be able to "click" on the button on the ribbon using vba
(basically execute the event with vba) and execute the command for the open
email (inspector). I don't want to modify the code. Unfortunately, I do not
have access to the source. Any ideas?

Sub RunIt()
Dim cb As Office.CommandBar
Dim cbb As Office.CommandBarButton
Dim ctrl As Office.CommandBarControl
Dim exp As Outlook.Explorer

Set exp = Application.ActiveExplorer
Set cb = exp.CommandBars("Standard")
For Each ctrl In cb.Controls
If ctrl.Caption = "Save to Vignette IDM" Then
Set cbb = ctrl
cbb.Execute
Exit For
End If
Next

Set cb = Nothing
Set cbb = Nothing
Set ctrl = Nothing
Set exp = Nothing
End Sub
Thanks.
 
If the code only works on a selected item in an Explorer then that won't
help you at all for an Inspector. The button code would need to work on
ActiveInspector, not on Selection(1).

I don't see any way of doing what you want unless you write your own code to
mirror the functions of the button, or you get the addin author to change
things for you.
 
Back
Top