Results 1 to 9 of 9

Thread: Merge field syntax problem

Hybrid View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2009
    Location
    Townsville, Qld, Australia
    Posts
    135

    Re: Merge field syntax problem

    I recorded a macro in Word, and this is what I got:

    Code:
    Sub Macro1()
    '
        ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
        Selection.TypeText Text:="Dear "
        WordBasic.MailMergeUseOutlookContacts
        ActiveDocument.Fields.Add Range:=Selection.Range, Type:=wdFieldMergeField _
            , Text:="""First"""
        Selection.TypeParagraph
        Selection.TypeText Text:="Test only."
    End Sub
    (The document that this produces looks like:

    Dear «First»
    Test only.

    BTW, this code was recorded in Word 2007, I know that "WordBasic" is anachronistic but that's what I got.

    I've also been going back to Word, to see what the Word help has to say, and the code looks quite different again.
    Last edited by Resource Dragon; Nov 28th, 2011 at 05:29 AM. Reason: Add further detail.

Posting Permissions

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



Click Here to Expand Forum to Full Width