+ Reply to Thread
Results 1 to 2 of 2

Excel VB Macro to Word Mail Merge to PDF.

  1. #1
    Registered User
    Join Date
    10-25-2012
    Location
    Washington DC
    MS-Off Ver
    For MS 365
    Posts
    54

    Excel VB Macro to Word Mail Merge to PDF.

    The code below opens a Word Mail Merge document, populates the Mail Merge fields with data from the active row of the worksheet, and prints that document to a PDF. Everything works fairly well except for the printing of PDF. The Word document gets populated with the correct row od data but, when the PDF gets created, all the Mail Merge fields are empty and the field codes get "printed".

    I've tried moving the print-to-PDF code around to different places, but I get the same results.

    Also, when the macro finishes the Word document stays open. Shouldn't the "wdocSource.Close SaveChanges:=False" statement close the file?

    Any ideas on what I'm doing wrong?

    Thank you very much.

    Please Login or Register  to view this content.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Excel VB Macro to Word Mail Merge to PDF.

    Hi, Max_Taylor,

    if I understand the syntax correctly the line
    Please Login or Register  to view this content.
    creates a new document so that whenever wdocSource is closed another document should remain open.

    As I use Bookmarks for the transfer from Excel to Word I canīt be of any help regarding the empty fields but both your variables WorkBookName as well as strWorkbookName could be simplified to ThisWorkbook.FullName.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1