Kathleane
05-14-2007, 06:52 PM
I've created a custom contact form in Outlook 2003 but of course I can't import my contacts from Access into that custom form. I went to the MS site and picked up a poorly written VB script that didn't work but I used that as a base to come up with the script below which doesn't work either but gets me a little further along.
I'm pretty much a novice with VB but I'm trying and at this point I've run aground. Would someone be willing to take a look at this script to see where I've run afoul of the VB rules? After the script I've written the two lines with error notes that seem to be the problem.
Sub ImportToCustom()
' Change the following line to your new Message Class
NewMC = "IPM.Contact.SU Sitters"
Set CurFolder = Application.ActiveExplorer.CurrentFolder
Set AlItems = CurFolder.Items
NumItems = CurFolder.Items.Count
' Loop through all of the items in the folder
For I = 1 To NumItems
Set CurItem = AllItems.Item(I)
' Test to see if the Message Class needs to be changed
If CurItem.MessageClass <> NewMC Then
Change the Message Class CurItem.MessageClass = NewMC
' Save the changed item
CurItem.Save End If Next MsgBox "Done."
End Sub
The error mssg I get when I run this script is:
Compile error:
Syntax error
And the following line is highlighted:
Change the Message Class CurItem.MessageClass = NewMC
There's a problem with this line too but I don't know what it is:
CurItem.Save End If Next MsgBox "Done."
I'm pretty much a novice with VB but I'm trying and at this point I've run aground. Would someone be willing to take a look at this script to see where I've run afoul of the VB rules? After the script I've written the two lines with error notes that seem to be the problem.
Sub ImportToCustom()
' Change the following line to your new Message Class
NewMC = "IPM.Contact.SU Sitters"
Set CurFolder = Application.ActiveExplorer.CurrentFolder
Set AlItems = CurFolder.Items
NumItems = CurFolder.Items.Count
' Loop through all of the items in the folder
For I = 1 To NumItems
Set CurItem = AllItems.Item(I)
' Test to see if the Message Class needs to be changed
If CurItem.MessageClass <> NewMC Then
Change the Message Class CurItem.MessageClass = NewMC
' Save the changed item
CurItem.Save End If Next MsgBox "Done."
End Sub
The error mssg I get when I run this script is:
Compile error:
Syntax error
And the following line is highlighted:
Change the Message Class CurItem.MessageClass = NewMC
There's a problem with this line too but I don't know what it is:
CurItem.Save End If Next MsgBox "Done."