MailMerge merges but not data...

T

T

Also, I'm using Word 2002 and my client has 2000. We'll
there be any quirks between the two versions?

Sub Test()

Dim CityCode
Dim cmd

CityCode = InputBox("Please, enter a city code to merge:")
cmd = "SELECT FirstName, LastName, City, State, Zip FROM
[EUQ_CurrentOwner] WHERE City = '" & CityCode & "' "

With ActiveDocument.MailMerge

.OpenDataSource Name:="", _

Connection:="DSN=BCS;DATABASE=bcs;uid=;pwd=", _
SQLStatement:=cmd, _
SubType:=wdMergeSubTypeWord2000


' Add merge fields.
.Fields.Add Selection.Range, "FirstName"
Selection.TypeText "Mr. "
.Fields.Add Selection.Range, "LastName"
Selection.TypeParagraph
.Fields.Add Selection.Range, "City"
Selection.TypeText ", "
.Fields.Add Selection.Range, "State"
Selection.TypeParagraph
.Fields.Add Selection.Range, "Zip"
Selection.TypeParagraph

.Destination = wdSendToNewDocument
.Execute
End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Insert variables into mailmerge documents 0
merge search to long 2
macro 2 issues 0
Mail Merge Functionality 0
word data from excel 0
MailMerge Macro Help 1
double merge 2
Real problems automating a mail merge 0

Top