Form called by actions...

C

curram

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
 
S

Sue Mosher [MVP-Outlook]

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.
 
H

Hollis Paul

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
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.
 
C

curram

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?
 
H

Hollis Paul

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.
 
K

Ken Slovak - [MVP - Outlook]

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.
 
H

Hollis Paul

Ken Slovak - [MVP - said:
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.
 

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