Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.pagelayout
|
|||
|
|||
![]()
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 OLEDB ![]() Password="""";Jet OLEDB:Engine Type=18;Jet OLEDB ![]() , 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
![]()
Posted to microsoft.public.word.pagelayout
|
|||
|
|||
![]()
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 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 OLEDB ![]() Password="""";Jet OLEDB:Engine Type=18;Jet OLEDB ![]() , 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 | |
|
|
![]() |
||||
Thread | Forum | |||
Mail merge leaves out job title from address block | Mailmerge | |||
mail merge address block name format is wrong | Mailmerge | |||
Mail merge, how can I set dif. case for address block &greeting | Mailmerge | |||
Need job title in mail merge Address block item | Microsoft Word Help | |||
Mail Merge Address Block Missing Address 3 | Mailmerge |