Results 1 to 3 of 3
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhook Word Mail merge (Word2000+)

    The code below is based on a recording of setting up a mail merge.
    I'd like to know what VBA code would unhook the mail merge.
    I know how to save the document as RTF, or copy/paste contents etc. to achieve much the same end, but then I'd lose document variables, macros etc.
    I can't see anything in the (Word) end-user interface that allows me to declare that a mail-merge document is to revert to non-merge status; if I could see that I'd record that, and poke through the entrails.
    I'm not even sure of my Lounge search terminology; "unhook" may not be the correct term.
    <pre> doc.MailMerge.DataSource.QueryString = ""
    With doc.MailMerge
    .Destination = wdSendToNewDocument
    .MailAsAttachment = False
    .MailAddressFieldName = ""
    .MailSubject = ""
    .SuppressBlankLines = True
    With .DataSource
    .FirstRecord = lngRecordNumber
    .LastRecord = lngRecordNumber
    End With
    .Execute Pause:=False
    Set docMergeOneRecord = ActiveDocument
    End With</pre>


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

    Re: Unhook Word Mail merge (Word2000+)

    ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument

    ActiveDocument can be replaced with a variable of type Document, of course.

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Unhook Word Mail merge (Word2000+)

    MainDocumentType Property: Returns or sets the mail merge main document type. Can be one of the following WdMailMergeMainDocType constants: wdCatalog, wdEnvelopes, wdFormLetters, wdMailingLabels, or wdNotAMergeDocument. Read/write Long. Note If you set this property for a document that's already a main document, the attached data source is removed.

    >ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument

    Aaaaaaaaaaaaaaaaaaaaaaaaaargh! It's now official. I'm losing one (or both) of my mind or my sight.

    Thanks Hans.
    It was staring at me right there in the Help screen and I didn't see it.

Posting Permissions

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