Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

cut/copy from one field to another

Posted on 2009-02-12
3
Medium Priority
?
219 Views
Last Modified: 2012-05-06
I'm trying to get information from fields in which I 'parked' information for custom fields.

I'm using a virtual basic script. I keep getting errors telling me that:

Automation error (Error 440)
   

When you access Automation objects, specific types of errors can occur. This error has the following cause and solution:

An error occurred while executing a method or getting or setting a property of an object variable. The error was reported by the application that created the object.
Check the properties of the Err object to determine the source and nature of the error. Also try using the On Error Resume Next statement immediately before the accessing statement, and then check for errors immediately following the accessing statement.

For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).


Why would this occur with this code? And could someone point to a place that lists each field's term in the VB script. Code is below
Sub ConvertFields()
  Dim objApp As Application
  Dim objNS As NameSpace
  Dim objFolder As MAPIFolder
  Dim objItems As Items
  Dim objItem As Object
 
  Set objApp = CreateObject("Outlook.Application")
  Set objNS = objApp.GetNamespace("MAPI")
  Set objFolder = objNS.PickFolder
  If Not objFolder Is Nothing Then
    Set objItems = objFolder.Items
    For Each objItem In objItems
      ' make sure you have a Contact item
      If objItem.Class = olContact Then
        ' convert to your published custom form
        objItem.MessageClass = "IPM.Contact.Recurrent Client"
        ' copy data to your custom fields
        objItem.UserProperties("Attorney 1") = objItem.User1
        objItem.UserProperties("Contact Date 1") = objItem.User2
        objItem.UserProperties("Matter 1") = objItem.User3
        objItem.UserProperties("Client Number 1") = objItem.User4
        objItem.UserProperties("Open Closed 1") = objItem.Anniversary
        objItem.UserProperties("Open Closed 2") = objItem.AssistantsPhone
        objItem.UserProperties("Attorney 3") = objItem.BusinessCountry
        objItem.UserProperties("Open Closed 3") = objItem.HomeCountry
        objItem.UserProperties("Matter 3") = objItem.OtherCountry
        objItem.UserProperties("Contact Method") = objItem.Callback
        objItem.UserProperties("Contact Date 4") = objItem.CarPhone
        objItem.UserProperties("Conflict") = objItem.CompanyMainPhone
        objItem.UserProperties("Attorney 2") = objItem.ISDN
        objItem.UserProperties("Contact Date 3") = objItem.RadioPhone
        objItem.UserProperties("Client Number 4") = objItem.TTYTDDPhone
        objItem.UserProperties("Client Number 3") = objItem.Telex
        objItem.UserProperties("Client Number 2") = objItem.Account
        objItem.UserProperties("Matter 4") = objItem.AssistantsName
        objItem.UserProperties("Open Closed 4") = objItem.BillingInformation
        objItem.NickName = objItem.BusinessAddressPOBox
        objItem.UserProperties("Internal Referral 1") = objItem.Email3Adress
        objItem.UserProperties("Internal Referral 2") = objItem.Email3Type
        objItem.UserProperties("Contact Date 2") = objItem.Email3DisplayName
        objItem.UserProperties("Client") = objItem.HomeAddressPOBox
        objItem.User1 = ""
        objItem.User2 = ""
        objItem.User3 = ""
        objItem.User4 = ""
        objItem.Anniversary = ""
        objItem.AssistantsPhone = ""
        objItem.BusinessCountry = ""
        objItem.HomeCountry = ""
        objItem.OtherCountry = ""
        objItem.Callback = ""
        objItem.CarPhone = ""
        objItem.CompanyMainPhone = ""
        objItem.ISDN = ""
        objItem.RadioPhone = ""
        objItem.TTYTDDPhone = ""
        objItem.Telex = ""
        objItem.Account = ""
        objItem.AssistantsName = ""
        objItem.BillingInformation = ""
        objItem.BusinessAddressPOBox = ""
        objItem.Email3Address = ""
        objItem.Email3Type = ""
        objItem.Email3DisplayName = ""
        objItem.HomeAddressPOBox = ""
        objItem.Save
      End If
    Next
  End If
 
  Set objItems = Nothing
  Set objItem = Nothing
  Set objFolder = Nothing
  Set objNS = Nothing
  Set objApp = Nothing
End Sub

Open in new window

0
Comment
Question by:fragilabsolut
  • 2
3 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 23631737
Hi, fragilabsolut.

"Why would this occur with this code? "
First, do you know what line of code is causing the error?  That would help a lot.  The code looks ok to me.  Without knowing where the error is occurring at, my guess is that some of the user properties don't exist when the code is trying to assign a value to them.  I don't believe that setting the MessageClass to yoour custom form creates the user properties.  I expect the code is going to have to create them before assigning a value to them.

"a place that lists each field's term in the VB script"
Sorry, I don't understand what you're asking.
0
 

Accepted Solution

by:
fragilabsolut earned 0 total points
ID: 23632518
Actually,  I figured out my problem.  I had some stuff incorrectly named.

That's what I was asking about with "a place that lists..."
For example:

{objItem.CarPhone} should have been {objItem.CarTelephoneNumber}

Thanks for the help.

0
 
LVL 76

Expert Comment

by:David Lee
ID: 23638036
You're welcome.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
Take a look at these 6 Outlook Email management tools which can augment the working and performance of Microsoft Outlook to give you a more rewarding emailing experience.
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question