![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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 |
Ads |
#2
|
|||
|
|||
![]()
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. -- 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 "Christopher Slowik" wrote in message ... 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 |
#3
|
|||
|
|||
![]()
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 "Ken Slovak - [MVP - Outlook]" 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. -- 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 "Christopher Slowik" wrote in message ... 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 |
#4
|
|||
|
|||
![]()
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. -- 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 "Christopher Slowik" wrote in message ... 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 |
#5
|
|||
|
|||
![]()
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 "Ken Slovak - [MVP - Outlook]" 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. -- 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 "Christopher Slowik" wrote in message ... 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 |
#6
|
|||
|
|||
![]()
Just for fun try it with this line instead:
objCB.ExecuteMso "ReviseContents" Of course this will only run without error on Outlook 2007... -- 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 "Christopher Slowik" wrote in message ... 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 |
#7
|
|||
|
|||
![]()
Same message Ken.....Invalid Procedure call or argument.
I'm stumped "Ken Slovak - [MVP - Outlook]" wrote: Just for fun try it with this line instead: objCB.ExecuteMso "ReviseContents" Of course this will only run without error on Outlook 2007... -- 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 "Christopher Slowik" wrote in message ... 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 |
#8
|
|||
|
|||
![]()
Let me check this out tomorrow and see what's going on.
-- 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 "Christopher Slowik" wrote in message ... Same message Ken.....Invalid Procedure call or argument. I'm stumped |
#9
|
|||
|
|||
![]()
Great....thanks Ken
"Ken Slovak - [MVP - Outlook]" wrote: Let me check this out tomorrow and see what's going on. -- 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 "Christopher Slowik" wrote in message ... Same message Ken.....Invalid Procedure call or argument. I'm stumped |
#10
|
|||
|
|||
![]()
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. -- 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 "Christopher Slowik" wrote in message ... Great....thanks Ken |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Displaying contents of a Custom Form | Kevin Smith | Outlook - Using Forms | 3 | April 7th 08 04:01 PM |
Custom form code not firing | karlman[_2_] | Outlook - Using Forms | 10 | January 4th 08 11:38 AM |
Custom form code not firing | karlman[_2_] | Outlook and VBA | 1 | January 2nd 08 09:53 PM |
Button to custom form | Uncle Vito | Outlook - Using Forms | 3 | March 3rd 07 02:06 PM |
Add Button To Form That Automatically Saves Contents To Text File | Dani | Outlook - Using Forms | 1 | September 19th 06 01:17 PM |