Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Aug 2001
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro to set field/record delimiters (Word 97 SR2)

    I am using a text file as my data source and would like to automate the merge procedure. I recorded a macro to select the header source and data source. When I play it, it prompts me to select the field and record delimiters for the data source. What else do I need to add to the codes below in order for me to set the field and record delimiters so I don't have to see the dialog box when the macro is played.

    Also, is there a way to perform a merge using the macro w/o opening the form letter?

    <pre>Sub Merge_Print()
    Dim aPath As String
    Dim aFormFile As String
    Dim aHeaderSource As String
    Dim aDataSource As String
    aPath = "Cocs"
    aFormFile = aPath & "Letter5B.doc"
    aHeaderSource = aPath & "Header.doc"
    aDataSource = aPath & "Data.dat"

    Documents.Open FileName:=aFormFile
    With ActiveDocument.MailMerge
    .OpenHeaderSource Name:=aHeaderSource
    .OpenDataSource Name:=aDataSource
    .Destination = wdSendToNewDocument
    With .DataSource
    .FirstRecord = wdDefaultFirstRecord
    .LastRecord = wdDefaultLastRecord
    End With
    .Execute Pause:=True
    End With
    End Sub
    </pre>



    --Maria

  2. #2
    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: Macro to set field/record delimiters (Word 97 SR2)

    If Word always guesses correctly, maybe this will help?

    .OpenDataSource Name:=aDataSource, Format:=wdOpenFormatText, ConfirmConversions:=False

  3. #3
    2 Star Lounger
    Join Date
    Aug 2001
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to set field/record delimiters (Word 97 SR2)

    Actually, I already tried that. I should have posted, sorry. <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>

    Any other ideas? BTW, the field delimiter I am using is ! and paragraph mark for record delimter.

    Thanks,
    --Maria

Posting Permissions

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