When an action is selected, I open a new form (specified on the Actions tab
as a reply, do not include original message.) The form has the following
code:
dim olns
Dim pgRequest
Function Item_Open()
msgbox "open form"
Set olns = Application.GetNameSpace("MAPI")
'Set the page
Set pgRequest = Item.GetInspector.ModifiedFormPages("Main")
msgbox "open"
End Function
Sub Item_CustomPropertyChange(ByVal Name)
on error goto 0
Set olns = Application.GetNameSpace("MAPI")
'Set the page
Set pgRequest = Item.GetInspector.ModifiedFormPages("Main")
msgbox "property"
...
End Sub
I receive the error message Object doesn't support this property or method:
'item.getinspector'" citing the line in the Item_CustomPropertyChange sub.
Then for each field on the form I get "You do not have appropriate
permissions to perform this operation". The "item_open" code never fires.
If I remove the Item_CustomPropertyChange sub code, the item_open code
executes without error.
Do you have ideas as to what is wrong?
Thanks
Sue Mosher [MVP-Outlook] - 26 Sep 2007 21:35 GMT
In general, CustomPropertyChange event handlers should use a Select block to monitor for changes in specific properties; see http://www.outlookcode.com/article.aspx?ID=38. The code you have in that event handler doesn't serve any obvious purpose, especially as it duplicates what is in Item_Open.
Also, you may want to use a module-level Boolean variable to track whether Outlook has opened the item. Set it to True after all other code has run in Item_Open and don't do your property change processing unless it is True.

Signature
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
> When an action is selected, I open a new form (specified on the Actions tab
> as a reply, do not include original message.) The form has the following
[quoted text clipped - 33 lines]
>
> Thanks
Hollis Paul - 26 Sep 2007 22:26 GMT
> dim olns
> Dim pgRequest
[quoted text clipped - 29 lines]
>
> Thanks
Since pgRequest is dim'd globally, initialized in the Item_Open event, and not
set to nothing anywhere, it can be used as long as the Item is open. It
really constitutes the "module-level Boolean variable" that Sue speaks of.
So, everywhere you want to return to your main page, just do pgRequest.show
and the main page will appear. However, you should correct your
Item_CustomPropertyChange sub code to use the expected Case format code, so
that it just fires in the case of your custom property changing. Otherwise,
you will have the main page flashing up every time you complete a field.
--
Hollis Paul
Mukilteo, WA USA
curram - 27 Sep 2007 13:47 GMT
My Item_CustomPropertyChange block does have the case statement...just didn't
feel the need to include it since my issue seems to be setting the page
request.
When I have the Item_CustomPropertyChange sub in my code the item_open
apparently does not execute since I do not get the open message, but when the
Item_CustomPropertyChange sub is deleted from the script the item_open code
executes.
I will see what happens without setting pgRequest in the
Item_CustomPropertyChange block
Thank you for your responses...any other ideas?
> > dim olns
> > Dim pgRequest
[quoted text clipped - 42 lines]
> Hollis Paul
> Mukilteo, WA USA
Hollis Paul - 27 Sep 2007 16:51 GMT
> Thank you for your responses...any other ideas?
This statement looks strange to me: "on error goto 0". I never used
anything but on error go to Next. It could be that goto 0 is a feature
that is not supported in VBScript. I would assume that, if you do not
get the Item-Open event when the property change sub is included, the
script engine is quitting when it can't load the entire script without
error. You should back out the suspect sub and bring it back line by
line to see what produces the failure.
--
Hollis Paul
Mukilteo, WA USA
Ken Slovak - [MVP - Outlook] - 27 Sep 2007 18:19 GMT
VBScript only supports On Error Resume Next.
On Error GoTo 0 or On Error GoTo ErrHandler type handling are for VB/VBA and
won't work at all with VBScript.

Signature
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
>> Thank you for your responses...any other ideas?
>>
[quoted text clipped - 9 lines]
> Hollis Paul
> Mukilteo, WA USA
Hollis Paul - 27 Sep 2007 23:01 GMT
> On Error Resume Next
Thanks, Ken, for the save. This old brain could only come up with on
Error goto Next, but that didn't seem right, either.
--
Hollis Paul
Mukilteo, WA USA