• Trouble using GetAddress method

    • This topic has 3 replies, 3 voices, and was last updated 13 years ago.
    Author
    Topic
    #483280

    I’m using the GetAddress method to retrieve Contact info from Outlook (using VBA in Word.) If I work with one Contact at a time, I have no trouble. If I display the dialog box to use To: and CC: fields, I run into problems.

    My code:

    Code:
    sAdddress = Application.GetAddress(“”, , _
        UseAutoText:=False, DisplaySelectDialog:=1, SelectDialog:=2)
    Debug.Print sAddress

    The value of sAddress is:
    Robert Alexander, Esq., Dr. David Sutton
    Anthony Adami, Jr., John Kamp

    That’s two To: Contacts and two CC: contacts. The To: and CC: contacts are separate by vbCrLf; Contacts are separated by a comma. But, as you can see above, there are commas in the Contact names, so I can’t Split the line with a comma as my delimiter.

    Is there any other way to retrieve the selected names so that I can then pass the individual names back to GetAddress to get the Contact info (company, address, etc.)?

    Thanks.

    Viewing 1 reply thread
    Author
    Replies
    • #1333914

      Is there a way to get the source of this info to separate the contact names by tabs instead of commas? Otherwise I can see no solution since there is no way to tell the program which commas separate parts of a contact and which separate contacts from one another. It is fatally ambiguous.

    • #1334049

      From your sample, a dirty way to do this might be to replace the ., pattern with something else eg

      sAddress = Replace(sAddress,”.,”,”.;”)

      Of course this would fail if fullstop comma appears somewhere else other than between addressees.

      • #1334051

        I think the possibility of failure is too great. “John Smith, Jr., M.D.” would be an example of the pattern you mention.

    Viewing 1 reply thread
    Reply To: Trouble using GetAddress method

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: