launch 'Revise Contents' with vba

U

Urs Ruefenacht

I fail to launch the 'Revise Contents' menu ("Edit | Revise Contents")
with the following code in the Item_Open Event:

Set objInspector = Item.GetInspector
Set objCommandBars = objInspector.CommandBars
Set objReviseContents = objCommandBars.FindControl(, 3273)

If Not objReviseContents Is Nothing Then
objReviseContents.Execute
End If
Set objReviseContents = Nothing


The objReviseContents is still nothing.
Is 3273 the wrong id?

thx in advance - cheers
oers
 
E

Eric Legault [MVP - Outlook]

You can also try doing it this way:

Dim objInspector As Outlook.Inspector
Dim objCommandBars As Office.CommandBars
Dim objCommandBar As Office.CommandBar
Dim objCBPU As Office.CommandBarPopup
Dim objReviseContents As Office.CommandBarControl

Set objInspector = Application.ActiveInspector
Set objCommandBars = objInspector.CommandBars
Set objCommandBar = objCommandBars.Item("Menu Bar")
Set objCBPU = objCommandBar.Controls("Edit")
Set objReviseContents = objCBPU.Controls("Revise Contents")
Set objReviseContents =
objCommandBar.FindControl(MsoControlType.msoControlButton, 3273)

If Not objReviseContents Is Nothing Then
objReviseContents.Execute
End If

Set objCBPU = Nothing
Set objInspector = Nothing
Set objCommandBar = Nothing
Set objCommandBars = Nothing
Set objReviseContents = Nothing
 
U

Urs Ruefenacht

With this code the object 'objReviseContents' will be created, but
objReviseContents.Execute has no effect in the Item_Open Event. If I
execute the same code in a button_Click event it works... what is the
difference?
 
E

Eric Legault [MVP - Outlook]

First, this is a redundant line of code that you should delete from my
previous post:

Set objReviseContents =
objCommandBar.FindControl(MsoControlType.msoControlButton, 3273)

I tried executing this button in the Item_Open and Inspector_Activate
events, and it looks like toolbar buttons cannot be executed programmatically
until after the form has completely loaded, which it won't be until after the
Item_Open/Inspector_Activate event. Makes sense, and truthfully I've never
tried executing toolbars in this context before so this is good to know!

The only other option I can think of is to use a Timer control on a custom
form (or Win32 API timer events) that will execute and fire the Revise
Contents button a few seconds after the form loads.
 
U

Urs Ruefenacht

Thanks - good idea with the timer. I don't have tried it yet.

Is there possibility to enable 'Revise Contents' globally or for a
single (custom) form in the outlook options or registry? In Outlook 2000
I don't have to revise contents for editing a reopened form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top