+ Reply to Thread
Results 1 to 1 of 1

Invalid merge field message although I am using right field names in word document

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Invalid merge field message although I am using right field names in word document

    Hi Guys

    I am writing the following code to print off the word letters but anyhow its saying Invalid merge field, "You want to remove it or replace it"

    But I am using right field names in the document. I have checked many times and they are right so not sure why its giving me invalid merge field message every time I run the code.

    Private Sub CmdPrint_Click()
    
    Application.DisplayAlerts = False
    Call Merge_123
    Application.DisplayAlerts = True
    
              
        MsgBox "The letters have been printed off."
    
    End Sub
    Sub Merge_123()
    MsgBox "Hello"
     strworkbookname = "J:\WilliamsLea-AIMM\Critical Document Handling\ODH System.mdb"
     
     With CreateObject("Word.Application").Documents.Add("C:\Documents and Settings\kaura2\Desktop\Reference.doc").MailMerge
      .MainDocumentType = 0
      .Destination = 1
      .OpenDataSource _
                Name:=strworkbookname, _
                AddToRecentFiles:=False, _
                Revert:=False, _
                Format:=wdOpenFormatAuto, _
                Connection:="Data Source=" & strworkbookname & ";Mode=Read", _
                sqlstatement:="SELECT * FROM `tblmaster` where Printpoolno='" & ComboBox2 & "'"
      .Execute
      .Parent.Close 0
     End With
     
     MsgBox "The letters have been printed off"
    End Sub
    Please see attached the word document as well. In the table there are following fields:
    Username,Surname,PolicyNo,Printpoolno,QADD,QAMM,QAYYYY

    I hope anyone can help me in this.

    Thanks
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to choose field- and record delimiter for a Mail Merge document using VBA
    By Pascal Lottaz in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 0
    Last Post: 11-06-2013, 05:57 PM
  2. Mail Merge - Excel Document - One field not pulling in
    By degross77 in forum Excel General
    Replies: 0
    Last Post: 08-30-2013, 02:14 PM
  3. export cell from excel to field in word document
    By andrea.aramburu in forum Excel General
    Replies: 1
    Last Post: 03-31-2011, 06:40 PM
  4. Replies: 0
    Last Post: 04-14-2009, 11:03 AM
  5. Replies: 0
    Last Post: 08-29-2005, 05:05 PM

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