cut/copy from one field to another

Posted on 2009-02-12
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 = ""


      End If


  End If

  Set objItems = Nothing

  Set objItem = Nothing

  Set objFolder = Nothing

  Set objNS = Nothing

  Set objApp = Nothing

End Sub

Open in new window

Question by:fragilabsolut
    LVL 76

    Expert Comment

    by:David Lee
    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.

    Accepted Solution

    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.

    LVL 76

    Expert Comment

    by:David Lee
    You're welcome.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
    Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
    This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now