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
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