Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Code in a mailmerge template
When I connect a mailmerge template to a text file via the Get Data button
on the MailMerge Helper in Word 2000, is there anywhere in the template that I can later view that path and file name where the template looks for its merge data. Where in the mailmerge template is the information stored? dixie |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Code in a mailmerge template
Run a macro containing the following code:
MsgBox ActiveDocument.MailMerge.DataSource.Name -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Dixie" wrote in message ... When I connect a mailmerge template to a text file via the Get Data button on the MailMerge Helper in Word 2000, is there anywhere in the template that I can later view that path and file name where the template looks for its merge data. Where in the mailmerge template is the information stored? dixie |
#3
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Code in a mailmerge template
I was looking for a way to change the data source in the mailmerge template
without navigating to the actual text file containing the data. There is only one letter difference between them and there are over 120 mailmerge templates. I have done one lot of them where I changed a C:\ to T:\ in a path and it took me just on two hours, including the sleep/trance time from the repetetiveness of the task. I have to do a quite a few of these from time to time and I was hoping I could find the path in some vba in the mailmerge template and just change the letter. No such luck I guess. The code you gave did report the path, but is not useful in changing it. Thanks anyway. dixie "Doug Robbins - Word MVP" wrote in message ... Run a macro containing the following code: MsgBox ActiveDocument.MailMerge.DataSource.Name -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Dixie" wrote in message ... When I connect a mailmerge template to a text file via the Get Data button on the MailMerge Helper in Word 2000, is there anywhere in the template that I can later view that path and file name where the template looks for its merge data. Where in the mailmerge template is the information stored? dixie |
#4
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Code in a mailmerge template
What follows is code I use to connect to a data source. Perhaps it will give
you a starting place. Function WorkGroupPath() As String ' Written by Charles Kenyon ' February 28, 2003 ' ' Used by templates menus to set location of templates. ' Returns workgroup tempates path with "\" at the end. ' ' This is needed because if the folder is a network drive rather ' than a folder, it will have the "\" already. If it is a folder, ' it will not have the backslash. This function gives a string ' with the backslash in either case. ' WorkGroupPath = Application.Options.DefaultFilePath(wdWorkgroupTem platesPath) If Right(WorkGroupPath, 1) "\" Then WorkGroupPath = WorkGroupPath & "\" End If End Function Sub AttachClients() ' Written by Charles Kenyon ' 19 April 2005 ' ' Requires WorkGroupPath function ' ' Makes activedocument a mailmerge (letter) document and ' attaches Clients_Merge.xls from Parts folder of Workgroup Templates folder. ' On Error Resume Next ' ' Name of file Dim strFileName As String Dim strProvider As String strFileName = WorkGroupPath & "Parts\Merge Data\Clients_Merge.xls" ' ' Attach Merge list ' ActiveDocument.MailMerge.OpenDataSource _ Name:=strFileName, _ 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=C:\Documents and Settings\All Users\Documents\MS Office User System Files\Shared Templates\Parts\Merge Data\Clients_Merge.xls;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:" _ , SQLStatement:="SELECT * FROM `Clients$`", SQLStatement1:="", SubType:= _ wdMergeSubTypeAccess ' ActiveDocument.MailMerge.OpenDataSource _ Name:=strFileName, _ 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=strFileName;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:" _ , SQLStatement:="SELECT * FROM `Clients$`", SQLStatement1:="", SubType:= _ wdMergeSubTypeAccess ' Following should be shorter version of above (somewhat) ActiveDocument.MailMerge.OpenDataSource strFileName, , , False, _ True, False, "", "", False, "", "", "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";Us er ID=Admin;Data Source=strFileName;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:" _ , "SELECT * FROM `Clients$`", "", , wdMergeSubTypeAccess ' ' Show merge data ActiveDocument.MailMerge.ViewMailMergeFieldCodes = False ' End Sub -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "Dixie" wrote in message ... I was looking for a way to change the data source in the mailmerge template without navigating to the actual text file containing the data. There is only one letter difference between them and there are over 120 mailmerge templates. I have done one lot of them where I changed a C:\ to T:\ in a path and it took me just on two hours, including the sleep/trance time from the repetetiveness of the task. I have to do a quite a few of these from time to time and I was hoping I could find the path in some vba in the mailmerge template and just change the letter. No such luck I guess. The code you gave did report the path, but is not useful in changing it. Thanks anyway. dixie "Doug Robbins - Word MVP" wrote in message ... Run a macro containing the following code: MsgBox ActiveDocument.MailMerge.DataSource.Name -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Dixie" wrote in message ... When I connect a mailmerge template to a text file via the Get Data button on the MailMerge Helper in Word 2000, is there anywhere in the template that I can later view that path and file name where the template looks for its merge data. Where in the mailmerge template is the information stored? dixie |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Global/Master Template | New Users | |||
I'm looking for a Word template that will emulate src code colors | Microsoft Word Help | |||
Help! Mailmerge code for all selected records? | Mailmerge | |||
Word Mailmerge does not display a ZIP code beginning with a zero. | Mailmerge | |||
Add code to select email field in mailmerge! | Mailmerge |