Outlook 2003 Custom Form Error Handling

M

Maui80

I would like to include some error handling in my VBScript on my custom form.
I've tried the On Error GoTo statement, but I keep getting a Syntax Error.
Then I've tried
On Error Resume Next
.... code to check ...
If Err <> 0 Then
.... do stuff
End If
But my error catching code does not seem to execute (I'm pretty sure my code
to check has a runtime error in it)

Basically, I have the following procedure call in one of my events:
Item.GetInspector ...
I know that it fails sometimes. I'd like to catch the error if my statement
fails and handle it.

Any suggestions?
Thanks in advance!
 
S

Sue Mosher [MVP]

VBScript does not support On Error GoTo. What you're doing with On Error
Resume Next and Err <> 0 is a good approach.

Item.GetInspector should never fail in a custom form. But if you're worried
that it might, this is the way to handle it:

On Error Resume Next
Set insp = Item.GetInspector
If insp Is Nothing Then
' there is no Inspector
Else
' do something with insp
End If
 
M

Maui80

Thank you so much for your quick reply. Your answer was helpful in helping me
find that I might be on the wrong track in finding the source of my problem.

the Item.GetInspector line is in my custom appointment form. When I allow
scripts to run on shared calendars and then I use my custom form to book a
resource, the resource that autoaccepts my invitiation shows a blank body of
the message. (This doesn't happen when 'allow scripts to run on shared
calendars' is disabled.)

When I remove that Item.GetInspector line, I'm finding that the body of my
appointment message is there fine.

That's why I thought perhaps the form class changes to something else in the
resource calendar response and GetInspector object would not exist...

I've been trying to figure this out on an off for weeks now - Do you have
any ideas?

thanks again for your last response!
 
M

Maui80

Also, I marked your answer as 'Yes' it helped because it was the right
response to my question. However, I'm still hoping someone will help me with
my bigger problem. Should I repost as a new question? Thanks!
 
M

Maui80

Oh and I forgot to add, my Item.GetInspector is in the event

Sub Item_CustomPropertyChange(ByVal Name)
 
M

Maui80

I have a custom tab on my appointment form. In it, I have a check box that
when the user checks or unchecks, it shows/hides a frame.

Sub Item_CustomPropertyChange(ByVal Name)
Select Case Name
Case "IsTrue"
Set oPage = Item.GetInspector.ModifiedFormPages
Set oCntrl = oPage("My Tab Name").Controls("My Control")
oCntrl.Visible = Item.UserProperties.Find("IsTrue").Value
Case "Etc"
....
End Select
End Sub

And when I mean 'blank body', I'm referring to the UI. In other words, the
message of the body is no longer there. I see the message body fine in my
calendar, but when I look at the calendar event in the resource calendar,
there is no message body.

In another post I made, the MVP suggested that when a user reply's, another
message class is used - IPM.Schedule.Meeting.Resp, and I would have to run
code to capture that item. So I tried checking if the

Item.MessageClass <> "IPM.Appointment.MyAppointment"

but that didn't help either...
 
S

Sue Mosher [MVP]

I'm still not clear on what you're doing. Is the user working with a check
box on an appointment in the Calendar folder or on a meeting request in the
Inbox?

I can't think of any reason why GetInspector would affect the item body. Is
there any code behind the form that touches the Body property?

Also, you said you have a resource calendar that autoaccepts invitations. If
this an autoaccept script, have you looked at its code? If it's Exchange
2007, is the resource calendar configured not to store appointment details?
(That's an option in 2007.)

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
M

Maui80

My custom form is a custom appointment form, so they are working with
appointments off the Calendar.

Yes, I am adding stuff to the Body property. To test, I decided to remove
all my code (so that it still works) that alters Item.Body. The behavior is
still the same - the message body is gone. Only when I remove that
Item.GetInspector code when the body of the message stays intact.

And yes, the resource calendar is set to autoaccept - but this is not using
a custom script. We're using Outlook 2003 on Exchange 2003 and are not even
using auto-accept agent. The way we set up our resource calendar was from
Tools > Options > Preferences (Tab) > Calendar Options (Button) > Resource
Scheduling (Button) > Automatically accept meeting requests... (option
checked). No extra bells and/or whistles. Perhaps Outlook 2003 has some
scripts running for that I don't know about?

It is still very strange that this behavior happens only when 'Allow Scripts
to Run on Shared Calendars' is checked.

Thanks for your patience.
 

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