Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Park City, Utah
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Data from Word to Outlook (Office 2003)

    Is it possible to use data from a Word document on the screen to populate the To and Subject fields of an e-mail message? I have the following simple text and the information where the @@ are will be used in creating the e-mail To field and the subject line.

    To: @@

    Account: @@
    Job No.: @@

    The user will replace the @@ with the data including using the Address Book and AddressLayout autotext to insert information. There are several macros that will help in the creation of this e-mail within Word, that is why we want to do it, but I have no idea if it is possible.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Data from Word to Outlook (Office 2003)

    You could create a userform in the Visual Basic Editor to let the user enter the text for the @@ bits, and use code to place the text in the document and to create an e-mail, for example using

    ActiveDocument.FollowHyperlink "mailto:" & Me.txtTo & "?subject=" & Me.txtSubject

    But the user wouldn't be able to use the address book etc. If you want to use the text from the document, it depends on how easy it is to determine what has been entered by the user. For example, if the text "To: " occurs only once in the document, it is safe to assume that what follows is the destination for the e-mail. But if the text "To: " can occur more than once, it becomes more difficult.

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Data from Word to Outlook (Office 2003)

    If the individual data "fields," such as they are, are marked with bookmarks, then a macro should be able to extract them fairly easily. We have a form where data actually is read out of Word form fields, but bookmarks should be roughly the same approach.

    Added: I was thinking that the message generated would be completely independent of the document on screen, rather than "mailing" the document itself.

  4. #4
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Park City, Utah
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Data from Word to Outlook (Office 2003)

    This is working perfectly for me. Just 1 more question, is there also a way I can pass some text to the body portion of the e-mail in the same way?

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Data from Word to Outlook (Office 2003)

    Yep. Use something like this:

    ActiveDocument.FollowHyperlink "mailto:" & Me.txtTo & "?subject=" & Me.txtSubject & "&body=My message"

    or

    ActiveDocument.FollowHyperlink "mailto:" & Me.txtTo & "?subject=" & Me.txtSubject & "&body=" & Me.txtBodyText

    See MailTo Syntax for more examples.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •