Address block problem in mail merge labels

S

SteveH

I'm using Word 2003. I am editing a mail merge document designed to print
labels from a database table. It was created by someone other than me. It is
opened with VBA code from a map editing app. I want to print the name
followed by a local township name by putting the township in the Company line
as such:

John Doe
Township name
Address

Currently, when I go to edit the address block and click the "Match fields"
button, the Courtesy Title is matched to the Township name field in the
table. However it is printing the Courtesy title first and appending the
name so it prints like this:

Township name John
Doe
address


I tried matching the field to the Company Name. It previews correctly but
when I same the document and open it with the mapping app, the address block
field matches I put in are changed back to the original settings. It is as
if something in the parameters within the code change the settings. I tried
doing a "Save As", changed the doc name (in the code as well) with the same
results.

Here's the code:

Dim MSWord As Word.Application


Set MSWord = New Word.Application
Dim WordDoc As Word.Document

'Set WordDoc =
MSWord.Documents.Open("J:\GIS_Developments\BnZ\Labels.doc")
Set WordDoc = MSWord.Documents.Open("X:\Steve\GIS\BnZ\Copy of
Labels2.doc")



MSWord.ActiveDocument.MailMerge.OpenDataSource
Name:="X:\Steve\GIS\BnZ\Labels.dbf", _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="",
Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User
ID=Admin;Data Source=X:\Temp;Mode=Read;Extended Properties="""";Jet
OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database
Password="""";Jet OLEDB:Engine Type=18;Jet OLEDB:Database Locking Mode" _
, SQLStatement:="SELECT * FROM `Labels`", SQLStatement1:="",
SubType _
:=wdMergeSubTypeAccess



MSWord.ActiveDocument.MailMerge.Execute False

MSWord.Selection.WholeStory
MSWord.Selection.Font.size = 10
MSWord.Selection.MoveRight Unit:=wdCharacter, Count:=1

MSWord.Documents(2).Close

MSWord.Visible = True


Help!
 
S

Suzanne S. Barnhill

Don't even try to use "Address Block" for this sort of application. Instead,
insert each individual merge field where you want it to go.
 

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

Top