VB Script code funtioning differently in different environments

M

Misty Khan

I have written some code in VB Script to update contacts
in a folder to a new custom contact form. The script also
prompts for data to be entered that will populate a new
user-defined field in the custom form. I've got the code
working on my lap top which runs Outlook 2000 in Windows
98, but when I sent the code to my desk top which runs
Outlook 2000 in Windows XP, it ran the part of the code
that udpates contacts to the new form, but would not save
the new form with the data added into the user-defined
field. Then I sent the same code to my client who is
running Outlook 2002 in Windows XP and when they run the
code it doesn't do anything. Does anyone know what the
problem might be?
 
S

Sue Mosher [MVP]

What do you mean by "sent the code"? Is this a standalone script, Outlook form, etc.? You might want to post a relevant snippet.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
M

Misty Khan

Sue,

Thanks for your note! Forgive my ignorance, but I'm not
sure what you mean by a snippet. Do you mean a little bit
of the code?

What I mean by "sent the code" is that I sent an e-mail
with a form attached that had the code imbedded in it in
VB Script.

The form has VB Script code that under certain conditions
specified in If statements converts contact forms in a
contact folder to customized contact forms. The script
also prompts the user for their name so that it can be
entered in a user-defined field in the custom form. All
of it ran just fine on my lap top, but as stated below,
broke down on the other two systems. The line that
triggered an error on the Outlook 2000/Windows XP system
was "CurItem.Save" in the following context:

Dim strspname
strspname = InputBox("Please enter your name.")
NewMC = "IPM.Contact.Custom Contact Form"
Set CurFolder = Application.ActiveExplorer.CurrentFolder
For I = 1 to CurFolder.Items.Count
Set CurItem = CurFolder.Items.Item(I)
If CurItem.MessageClass = NewMC Then
CurItem.UserProperties.Find("Your Name") = strspname
CurItem.Save
End If
Next

The same code "CurItem.Save" had been used earlier in the
same subroutine with no issues, but for some reason I got
an error message for that line in this part of the code.

Any help you can give me would be greatly appreciated!

Regards,

Misty
-----Original Message-----
What do you mean by "sent the code"? Is this a standalone
script, Outlook form, etc.? You might want to post a
relevant snippet.
 
S

Sue Mosher [MVP]

Yes, snippet = a little bit, just enough to show the techniques you're using.

Where is the form published? In Outlook 2002 and secure versions of Outlook 2000 and 98, code does not run on unpublished or one-off forms. See http://www.slipstick.com/outlook/esecup.htm#formsec

What error message did you receive?
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP]

An item created with a published form can become a one-off item when code behind the form runs and accesses a property or method known to cause one-offing, such as PossibleValues. Items with a size of 1kb are unlikely to be one-offs. Checking the value Message Class property is the other test.

Asking again, what error message are you receiving from the statement that triggers the error?

I don't know what you might mean by "linked forms scenario."
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
M

Misty Khan

I checked the message class and it is the message class
for the custom form and not the standard message class -
also the icon is for a custom form as opposed to the
standard Outlook contact message class. So it doesn't
look like the forms for the contacts in the folder are one-
off yet. Strange though, beacuse they do have the
Possible Values property - not in VB code, but just in the
properties values accessed from design mode.

The error message I am receiving is: Script error -
"Unable to save this Item. Line No. 51"

Line no. 51 is "CurItem.Save". That is the same code that
I used previously in the subroutine to save the form after
the message class was changed to the new custom form.

-----Original Message-----
An item created with a published form can become a one-
off item when code behind the form runs and accesses a
property or method known to cause one-offing, such as
PossibleValues. Items with a size of 1kb are unlikely to
be one-offs. Checking the value Message Class property is
the other test.
Asking again, what error message are you receiving from
the statement that triggers the error?
 

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