Custom Form and firing Revise Contents button

  • Thread starter Q2hyaXN0b3BoZXIgU2xvd2lr
  • Start date
Status
Not open for further replies.
Q

Q2hyaXN0b3BoZXIgU2xvd2lr

Hi,

We have a custom form that creates a post in a public folder. In Outlook

2007, when a user opens a posting in this folder, they cannot edit the body

of the post until they click the "Revise Contents" button. I'd like to

execute this button on the Item_Open event so they do not have to click this

manually. I have the code below, but nothing seems to happen:

Dim objInsp

Dim colCB

Dim objCBB

On Error Resume Next

Set objInsp = Item.GetInspector

Set colCB = objInsp.CommandBars

Set objCBB = colCB.FindControl(, 3273)

If Not objCBB Is Nothing Then

'MsgBox objCBB.Caption

objCBB.Execute

End If

Set objCBB = Nothing

Set colCB = Nothing

Set objInsp = Nothing

Thanks for any help

-Chris
 
K

Ken Slovak - [MVP - Outlook]

In the Outlook 2007 Ribbon that ribbon control has an idMso of

"ReviseContents". Use Inspector.CommandBars.ExecuteMso("ReviseContents") on

open to do what you want.

"Christopher Slowik" <ChristopherSlowik> wrote in

message news:8B89A15B-9C53-4B06-9AB0-D46211444E91@microsoft.com...
> Hi,

> We have a custom form that creates a post in a public folder. In Outlook
> 2007, when a user opens a posting in this folder, they cannot edit the
> body
> of the post until they click the "Revise Contents" button. I'd like to
> execute this button on the Item_Open event so they do not have to click
> this
> manually. I have the code below, but nothing seems to happen:

> Dim objInsp
> Dim colCB
> Dim objCBB
> On Error Resume Next
> Set objInsp = Item.GetInspector
> Set colCB = objInsp.CommandBars
> Set objCBB = colCB.FindControl(, 3273)
> If Not objCBB Is Nothing Then
> 'MsgBox objCBB.Caption
> objCBB.Execute
> End If
> Set objCBB = Nothing
> Set colCB = Nothing
> Set objInsp = Nothing

> Thanks for any help

> -Chris
>
 
Q

Q2hyaXN0b3BoZXIgU2xvd2lr

Ken, thanks for the information. I still cannot get this to fire. As a

test, I created a standard Post Item in a test folder. Placed the code below

in the Item_Open event but it never seems to fire.

MsgBox "Here we are"

Dim objInsp

On Error Resume Next

Set objInsp = Item.GetInspector

objInsp.CommandBars.ExecuteMso("ReviseContents")

Set objInsp = Nothing

Thanks
wrote:


> In the Outlook 2007 Ribbon that ribbon control has an idMso of
> "ReviseContents". Use Inspector.CommandBars.ExecuteMso("ReviseContents") on
> open to do what you want.

> >

>

> "Christopher Slowik" <ChristopherSlowik> wrote in
> message news:8B89A15B-9C53-4B06-9AB0-D46211444E91@microsoft.com...
> > Hi,
> > We have a custom form that creates a post in a public folder. In Outlook
> > 2007, when a user opens a posting in this folder, they cannot edit the
> > body
> > of the post until they click the "Revise Contents" button. I'd like to
> > execute this button on the Item_Open event so they do not have to click
> > this
> > manually. I have the code below, but nothing seems to happen:
> > Dim objInsp
> > Dim colCB
> > Dim objCBB
> > On Error Resume Next
> > Set objInsp = Item.GetInspector
> > Set colCB = objInsp.CommandBars
> > Set objCBB = colCB.FindControl(, 3273)
> > If Not objCBB Is Nothing Then
> > 'MsgBox objCBB.Caption
> > objCBB.Execute
> > End If
> > Set objCBB = Nothing
> > Set colCB = Nothing
> > Set objInsp = Nothing
> > Thanks for any help
> > -Chris
> >


>
 
K

Ken Slovak - [MVP - Outlook]

Are you saying the MsgBox doesn't fire or something else?

In some cases things are only weak object references at the time the

Item_Open() event fires in form code.

In an addin I'd get those things in the first Inspector.Activate() event

handler, but that can't be done in form code. I also sometimes use a timer

to wait out the completion of an event, but again that can't be done in form

code.

I'd comment out the On Error line and see what line fires an error. In

addition, I'd also set up a CommandBars object and instantiate that as

objInsp.CommandBars, then if that was valid I'd call ExecuteMso() on that

object.

"Christopher Slowik" <ChristopherSlowik> wrote in

message news:1D80521B-E17D-4558-9AB2-B9E1DD4D4DC6@microsoft.com...
> Ken, thanks for the information. I still cannot get this to fire. As a
> test, I created a standard Post Item in a test folder. Placed the code
> below
> in the Item_Open event but it never seems to fire.

> MsgBox "Here we are"
> Dim objInsp
> On Error Resume Next
> Set objInsp = Item.GetInspector
> objInsp.CommandBars.ExecuteMso("ReviseContents")
> Set objInsp = Nothing

> Thanks
 
Q

Q2hyaXN0b3BoZXIgU2xvd2lr

Hi Ken,

No the MsgBox fires. Here is the changed code.

Dim objInsp

Dim objCB

'On Error Resume Next

Set objInsp = Item.GetInspector

Set objCB = objInsp.CommandBars

If Not objCB Is Nothing Then

MsgBox "Here we are with objCB"

objCB.ExecuteMso("ReviseContents")

End If

Set objInsp = Nothing

Set objCB = Nothing

the line "objCB.ExecuteMso("ReviseContents")" throws the following error:

Invalid procedure call or argument

Line No:11
wrote:


> Are you saying the MsgBox doesn't fire or something else?

> In some cases things are only weak object references at the time the
> Item_Open() event fires in form code.

> In an addin I'd get those things in the first Inspector.Activate() event
> handler, but that can't be done in form code. I also sometimes use a timer
> to wait out the completion of an event, but again that can't be done in form
> code.

> I'd comment out the On Error line and see what line fires an error. In
> addition, I'd also set up a CommandBars object and instantiate that as
> objInsp.CommandBars, then if that was valid I'd call ExecuteMso() on that
> object.

> >

>

> "Christopher Slowik" <ChristopherSlowik> wrote in
> message news:1D80521B-E17D-4558-9AB2-B9E1DD4D4DC6@microsoft.com...
> > Ken, thanks for the information. I still cannot get this to fire. As a
> > test, I created a standard Post Item in a test folder. Placed the code
> > below
> > in the Item_Open event but it never seems to fire.
> > MsgBox "Here we are"
> > Dim objInsp
> > On Error Resume Next
> > Set objInsp = Item.GetInspector
> > objInsp.CommandBars.ExecuteMso("ReviseContents")
> > Set objInsp = Nothing
> > Thanks


>
 
K

Ken Slovak - [MVP - Outlook]

Just for fun try it with this line instead:

objCB.ExecuteMso "ReviseContents"

Of course this will only run without error on Outlook 2007...

"Christopher Slowik" <ChristopherSlowik> wrote in

message news:76B2AC1B-62F8-4824-9103-217B29AB1B88@microsoft.com...
> Hi Ken,

> No the MsgBox fires. Here is the changed code.

> Dim objInsp
> Dim objCB
> 'On Error Resume Next
> Set objInsp = Item.GetInspector
> Set objCB = objInsp.CommandBars
> If Not objCB Is Nothing Then
> MsgBox "Here we are with objCB"
> objCB.ExecuteMso("ReviseContents")
> End If

> Set objInsp = Nothing
> Set objCB = Nothing

> the line "objCB.ExecuteMso("ReviseContents")" throws the following error:

> Invalid procedure call or argument
> Line No:11
 
Q

Q2hyaXN0b3BoZXIgU2xvd2lr

Same message Ken.....Invalid Procedure call or argument.

I'm stumped
wrote:


> Just for fun try it with this line instead:

> objCB.ExecuteMso "ReviseContents"

> Of course this will only run without error on Outlook 2007...

> >

>

> "Christopher Slowik" <ChristopherSlowik> wrote in
> message news:76B2AC1B-62F8-4824-9103-217B29AB1B88@microsoft.com...
> > Hi Ken,
> > No the MsgBox fires. Here is the changed code.
> > Dim objInsp
> > Dim objCB
> > 'On Error Resume Next
> > Set objInsp = Item.GetInspector
> > Set objCB = objInsp.CommandBars
> > If Not objCB Is Nothing Then
> > MsgBox "Here we are with objCB"
> > objCB.ExecuteMso("ReviseContents")
> > End If
> > Set objInsp = Nothing
> > Set objCB = Nothing
> > the line "objCB.ExecuteMso("ReviseContents")" throws the following error:
> > Invalid procedure call or argument
> > Line No:11


>
 
K

Ken Slovak - [MVP - Outlook]

Let me check this out tomorrow and see what's going on.

"Christopher Slowik" <ChristopherSlowik> wrote in

message news:031E93A0-2CA9-4C1C-A66D-C3B42B47E53B@microsoft.com...
> Same message Ken.....Invalid Procedure call or argument.

> I'm stumped
 
Q

Q2hyaXN0b3BoZXIgU2xvd2lr

Great....thanks Ken
wrote:


> Let me check this out tomorrow and see what's going on.

> >

>

> "Christopher Slowik" <ChristopherSlowik> wrote in
> message news:031E93A0-2CA9-4C1C-A66D-C3B42B47E53B@microsoft.com...
> > Same message Ken.....Invalid Procedure call or argument.
> > I'm stumped


>
 
K

Ken Slovak - [MVP - Outlook]

It looks like the added methods in the CommandBars collection aren't

available at all in Item_Open, either in form code or in Outlook VBA. They

are available when the first Inspector.Activate() event fires.

I hit an error both in the form code and Outlook VBA when I called

CommandBars.ExecuteMso() in Item_Open. I didn't in the first

Inspector.Activate() on that Inspector, however that's not an event you can

sink in form code.

The other gotcha related to this is that calling

ExecuteMso("ReviseContents") will open a new Inspector and close the

existing one (same item, but now in edit mode). So any Activate() code would

have to account for that since both NewInspector() and Inspector.Activate()

will fire again when that new Inspector is opened.

"Christopher Slowik" <ChristopherSlowik> wrote in

message news:4B825082-3262-408B-9610-9D416E39226A@microsoft.com...
> Great....thanks Ken
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
Z Command button no longer firing after sending custom form over ema Outlook VBA and Custom Forms 1
J Does the .fdm contain my custom form? How to make ol use it? - ol2007 Outlook VBA and Custom Forms 4
J ol2021 custom form not displaying pics Outlook VBA and Custom Forms 37
cbufacchi Outlook 365 Populate custom Outlook Appoint form Outlook VBA and Custom Forms 2
C Create Meeting With Custom Form Outlook VBA and Custom Forms 2
J custom form not displaying pictures Outlook VBA and Custom Forms 7
I Button PDF in Outlook Contact custom form Outlook VBA and Custom Forms 1
K Font Sizing in Custom Form Regions for Contacts Outlook VBA and Custom Forms 1
K can't get custom form to update multiple contacts using VBA Outlook VBA and Custom Forms 3
H Custom Outlook Contact Form VBA Outlook VBA and Custom Forms 1
F Validation on custom task form after task acceptance Outlook VBA and Custom Forms 1
I Error saving screenshots in a custom form in outlook 2016, outlook 365 - ok in outlook 2013, outlook 2010 Outlook VBA and Custom Forms 5
M VbScript for Command Button on Contacts Custom Form Using Outlook 1
G Other users can't see P.2 with custom fields in Form Outlook VBA and Custom Forms 0
O Create a custom contact form - questions before messing things up... Outlook VBA and Custom Forms 4
L Custom Form Tutoral? Outlook VBA and Custom Forms 6
D Lost Access to Custom Form Outlook VBA and Custom Forms 4
M vCard does not have user-defined fields from my custom contact form (365) Using Outlook 1
S Outlook Custom Form Scripting only working when clicking on "Run this form" Outlook VBA and Custom Forms 2
Victor_50 Outlook 2013 Custom Contact Form starts with "E-mail 2" Outlook VBA and Custom Forms 2
C Custom Form (seperate layout pages and message reading pane) Outlook VBA and Custom Forms 0
C Reading Pane for Custom Form Outlook VBA and Custom Forms 2
N Custom Form Controls Not Visible To Recipient Outlook VBA and Custom Forms 3
Randy Redekopp How To Merge Contact Info to Email Custom Form Template Using Outlook 2
D Problem with custom form including _DocSiteControl1 Outlook VBA and Custom Forms 0
C Custom Outlook Form - Populate Information from Radio Button / Check Box Using Outlook 0
W Message class changes of a custom form changes to the default form Using Outlook 2
A Possible to hide ribbon with custom appointment form? Outlook VBA and Custom Forms 3
S Custom Form, copy user field data to message body Outlook VBA and Custom Forms 12
Andrew Quirl Custom form to route requests based on input criteria Outlook VBA and Custom Forms 1
D Using a VBA Custom Form to Send Reoccurring Email Upon Task Completion Outlook VBA and Custom Forms 4
W Setting up a custom form Outlook VBA and Custom Forms 2
A Greyed out checkbox in custom form Outlook VBA and Custom Forms 4
Z Outlook Custom Form: Adding Dropdown(Project Code) at the end of subject Outlook VBA and Custom Forms 0
Z Adding dropdown list using custom form Outlook VBA and Custom Forms 7
J autocomplete function in custom form Using Outlook 1
D Custom form with html hyperlink Outlook VBA and Custom Forms 7
D populating listbox on custom form from Access Outlook VBA and Custom Forms 7
D Custom Form Accept and Reject Command buttons Outlook VBA and Custom Forms 2
D create an html table in outlook custom form 2010 using vba in MsAccess Outlook VBA and Custom Forms 7
Potty Ash MS Outlook 2010 custom form - validation or formula to request user to check a checkbox Outlook VBA and Custom Forms 16
J Custom form code doesn't run Outlook VBA and Custom Forms 2
R Custom Contact Form how to update when loaded. Outlook VBA and Custom Forms 6
G Copy Contact field to Appointment Custom Form Field Outlook VBA and Custom Forms 2
S Custom form with dropdown Using Outlook 0
P Custom form reverts from task Outlook VBA and Custom Forms 1
L Create Custom Form Using Outlook 0
L Outlook Custom Form Using Outlook 2
Diane Poremsky The custom form cannot be opened. Outlook will use an Outlook form instead. Using Outlook 0
Y Creating custom appointment request form with multiple mail recipients Outlook VBA and Custom Forms 5

Similar threads

Top