Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.pagelayout
SteveH SteveH is offline
external usenet poster
 
Posts: 19
Default Address block problem in mail merge labels

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\Lab els.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="""";Us er
ID=Admin;Data Source=X:\Temp;Mode=Read;Extended Properties="""";Jet
OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDBatabase
Password="""";Jet OLEDB:Engine Type=18;Jet OLEDBatabase 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!
--
Steve
  #2   Report Post  
Posted to microsoft.public.word.pagelayout
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Address block problem in mail merge labels

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.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

"SteveH" wrote in message
...
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\Lab els.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="""";Us er
ID=Admin;Data Source=X:\Temp;Mode=Read;Extended Properties="""";Jet
OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDBatabase
Password="""";Jet OLEDB:Engine Type=18;Jet OLEDBatabase 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!
--
Steve



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail merge leaves out job title from address block Don Burgess Mailmerge 5 February 1st 24 09:37 AM
mail merge address block name format is wrong jewelb Mailmerge 3 April 4th 08 07:59 AM
Mail merge, how can I set dif. case for address block &greeting RetiredRose Mailmerge 4 January 31st 07 06:43 PM
Need job title in mail merge Address block item Worksmart Microsoft Word Help 1 March 4th 06 12:48 AM
Mail Merge Address Block Missing Address 3 Joe Champagne Mailmerge 3 September 23rd 05 06:09 PM


All times are GMT +1. The time now is 09:48 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"