Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
File Names for MailMerge Documents
How do you save a new document generated from an existing MailMerge
Template/Document as the same name as the original document/template rather than MS Word creating a new document with the merge info and calling it "Letter1." For example, if my original document with the merge fields in it is called Kristen when I select the merge function and the new document opens, I want it to default to the name Kristen.doc when I use the File-SaveAs command and then I will edit the file name before saving to be Kristen013107(or something unique) before saving it so that it doesn't overwrite the original Kristen.doc base merge template. Likewise, is there a way after you save a file that is in a specified directory after it has been merged, to have this file moved and/or copied to another specified directory. Thanks in advance for any help! |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
File Names for MailMerge Documents
The document doesn't have a name until it is saved Letter1 is simply Word's
internal description. If you want individual merge letters named from the data - see http://www.gmayor.com/individual_merge_letters.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Kristen wrote: How do you save a new document generated from an existing MailMerge Template/Document as the same name as the original document/template rather than MS Word creating a new document with the merge info and calling it "Letter1." For example, if my original document with the merge fields in it is called Kristen when I select the merge function and the new document opens, I want it to default to the name Kristen.doc when I use the File-SaveAs command and then I will edit the file name before saving to be Kristen013107(or something unique) before saving it so that it doesn't overwrite the original Kristen.doc base merge template. Likewise, is there a way after you save a file that is in a specified directory after it has been merged, to have this file moved and/or copied to another specified directory. Thanks in advance for any help! |
#3
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
File Names for MailMerge Documents
Thanks for the link Graham. The problem is that this macro also splits the
document into a new document for each record. Basically what I want is to have the new document named via a data line in the main document like this does, but not the other part with the splitting. Do you know where I can find how to do this. It seems like it should be a fairly common request. Thanks in advance! "Graham Mayor" wrote: The document doesn't have a name until it is saved Letter1 is simply Word's internal description. If you want individual merge letters named from the data - see http://www.gmayor.com/individual_merge_letters.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Kristen wrote: How do you save a new document generated from an existing MailMerge Template/Document as the same name as the original document/template rather than MS Word creating a new document with the merge info and calling it "Letter1." For example, if my original document with the merge fields in it is called Kristen when I select the merge function and the new document opens, I want it to default to the name Kristen.doc when I use the File-SaveAs command and then I will edit the file name before saving to be Kristen013107(or something unique) before saving it so that it doesn't overwrite the original Kristen.doc base merge template. Likewise, is there a way after you save a file that is in a specified directory after it has been merged, to have this file moved and/or copied to another specified directory. Thanks in advance for any help! |
#4
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
File Names for MailMerge Documents
This sounds like you want to create 'versions' - see another macro on my web
site at http://www.gmayor.com/save_numbered_versions.htm which could be adapted to your requirements -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Kristen wrote: Thanks for the link Graham. The problem is that this macro also splits the document into a new document for each record. Basically what I want is to have the new document named via a data line in the main document like this does, but not the other part with the splitting. Do you know where I can find how to do this. It seems like it should be a fairly common request. Thanks in advance! "Graham Mayor" wrote: The document doesn't have a name until it is saved Letter1 is simply Word's internal description. If you want individual merge letters named from the data - see http://www.gmayor.com/individual_merge_letters.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Kristen wrote: How do you save a new document generated from an existing MailMerge Template/Document as the same name as the original document/template rather than MS Word creating a new document with the merge info and calling it "Letter1." For example, if my original document with the merge fields in it is called Kristen when I select the merge function and the new document opens, I want it to default to the name Kristen.doc when I use the File-SaveAs command and then I will edit the file name before saving to be Kristen013107(or something unique) before saving it so that it doesn't overwrite the original Kristen.doc base merge template. Likewise, is there a way after you save a file that is in a specified directory after it has been merged, to have this file moved and/or copied to another specified directory. Thanks in advance for any help! |
#5
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
File Names for MailMerge Documents
Hi Graham,
I actually don't want version numbers because the document needs to have the result of a merged data field. Maybe it would be easier if I gave you an example. The merge document has a Case ID# in it called Case_ID. The name of the document is SoftwareNotice.doc. When the new document is created after the merge, when I go to Save it, I want it to look at the merge field Case_ID and name the document SoftwareNotice1234.doc, assuming that 1234 was the Case_ID. Does this make sense? Thanks for all of your help and prompt responses! "Graham Mayor" wrote: This sounds like you want to create 'versions' - see another macro on my web site at http://www.gmayor.com/save_numbered_versions.htm which could be adapted to your requirements -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Kristen wrote: Thanks for the link Graham. The problem is that this macro also splits the document into a new document for each record. Basically what I want is to have the new document named via a data line in the main document like this does, but not the other part with the splitting. Do you know where I can find how to do this. It seems like it should be a fairly common request. Thanks in advance! "Graham Mayor" wrote: The document doesn't have a name until it is saved Letter1 is simply Word's internal description. If you want individual merge letters named from the data - see http://www.gmayor.com/individual_merge_letters.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Kristen wrote: How do you save a new document generated from an existing MailMerge Template/Document as the same name as the original document/template rather than MS Word creating a new document with the merge info and calling it "Letter1." For example, if my original document with the merge fields in it is called Kristen when I select the merge function and the new document opens, I want it to default to the name Kristen.doc when I use the File-SaveAs command and then I will edit the file name before saving to be Kristen013107(or something unique) before saving it so that it doesn't overwrite the original Kristen.doc base merge template. Likewise, is there a way after you save a file that is in a specified directory after it has been merged, to have this file moved and/or copied to another specified directory. Thanks in advance for any help! |
#6
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
File Names for MailMerge Documents
You can use a macro like the following to perform the merge, but only if
your mail merge main document does not have any Next record fields and similar stuff such as Next record if Peter Jamieson Sub ProduceOneDocPerSourceRec() ' ' NB, needs bettor error management and doubtless other things a VBA expert ' will point out. Dim intSourceRecord Dim objMerge As Word.MailMerge Dim strEman As String Dim strOutputDocumentName As String Dim TerminateMerge As Boolean ' Need to set up this object as the ActiveDocument changes when the ' merge is performed. Besides, it's clearer. Set objMerge = ActiveDocument.MailMerge With objMerge ' If no data source has been defined, do it here using OpenDataSource. ' But if it is already defined in the document, you should not need to define it here. ' .OpenDataSource _ ' Name:="whatever" intSourceRecord = 1 TerminateMerge = False Do Until TerminateMerge .DataSource.ActiveRecord = intSourceRecord ' if we have gone past the end (and possibly, if there are no records) ' then the Activerecord will not be what we have just tried to set it to If .DataSource.ActiveRecord intSourceRecord Then TerminateMerge = True ' the record exists Else ' while we are looking at the correct activerecord, ' create the document path name ' e.g. - you will need to change this - strEman = StrReverse(objMerge.Name) StrReverse(Mid(strEman, InStr(1, strEman & ".", ".") + 1)) strOutputDocumentName = _ "c:\mydoc\" & _ StrReverse(Mid(strEman, InStr(1, strEman & ".", ".") + 1)) & _ .DataSource.Datafields("CaseID").Value & ".doc" .DataSource.FirstRecord = intSourceRecord .DataSource.LastRecord = intSourceRecord .Destination = wdSendToNewDocument .Execute ' The Activedocument is always the output document ' Add any parameters you need to these calls ActiveDocument.SaveAs strOutputDocumentName ActiveDocument.Close intSourceRecord = intSourceRecord + 1 End If Loop End With End Sub "Kristen" wrote in message ... Hi Graham, I actually don't want version numbers because the document needs to have the result of a merged data field. Maybe it would be easier if I gave you an example. The merge document has a Case ID# in it called Case_ID. The name of the document is SoftwareNotice.doc. When the new document is created after the merge, when I go to Save it, I want it to look at the merge field Case_ID and name the document SoftwareNotice1234.doc, assuming that 1234 was the Case_ID. Does this make sense? Thanks for all of your help and prompt responses! "Graham Mayor" wrote: This sounds like you want to create 'versions' - see another macro on my web site at http://www.gmayor.com/save_numbered_versions.htm which could be adapted to your requirements -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Kristen wrote: Thanks for the link Graham. The problem is that this macro also splits the document into a new document for each record. Basically what I want is to have the new document named via a data line in the main document like this does, but not the other part with the splitting. Do you know where I can find how to do this. It seems like it should be a fairly common request. Thanks in advance! "Graham Mayor" wrote: The document doesn't have a name until it is saved Letter1 is simply Word's internal description. If you want individual merge letters named from the data - see http://www.gmayor.com/individual_merge_letters.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Kristen wrote: How do you save a new document generated from an existing MailMerge Template/Document as the same name as the original document/template rather than MS Word creating a new document with the merge info and calling it "Letter1." For example, if my original document with the merge fields in it is called Kristen when I select the merge function and the new document opens, I want it to default to the name Kristen.doc when I use the File-SaveAs command and then I will edit the file name before saving to be Kristen013107(or something unique) before saving it so that it doesn't overwrite the original Kristen.doc base merge template. Likewise, is there a way after you save a file that is in a specified directory after it has been merged, to have this file moved and/or copied to another specified directory. Thanks in advance for any help! |
#7
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
File Names for MailMerge Documents
Hmmm. If it's a single record merge then the original split merge add-in
solution should work. This names the file from a field (CaseID) in the document? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Kristen wrote: Hi Graham, I actually don't want version numbers because the document needs to have the result of a merged data field. Maybe it would be easier if I gave you an example. The merge document has a Case ID# in it called Case_ID. The name of the document is SoftwareNotice.doc. When the new document is created after the merge, when I go to Save it, I want it to look at the merge field Case_ID and name the document SoftwareNotice1234.doc, assuming that 1234 was the Case_ID. Does this make sense? Thanks for all of your help and prompt responses! "Graham Mayor" wrote: This sounds like you want to create 'versions' - see another macro on my web site at http://www.gmayor.com/save_numbered_versions.htm which could be adapted to your requirements -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Kristen wrote: Thanks for the link Graham. The problem is that this macro also splits the document into a new document for each record. Basically what I want is to have the new document named via a data line in the main document like this does, but not the other part with the splitting. Do you know where I can find how to do this. It seems like it should be a fairly common request. Thanks in advance! "Graham Mayor" wrote: The document doesn't have a name until it is saved Letter1 is simply Word's internal description. If you want individual merge letters named from the data - see http://www.gmayor.com/individual_merge_letters.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Kristen wrote: How do you save a new document generated from an existing MailMerge Template/Document as the same name as the original document/template rather than MS Word creating a new document with the merge info and calling it "Letter1." For example, if my original document with the merge fields in it is called Kristen when I select the merge function and the new document opens, I want it to default to the name Kristen.doc when I use the File-SaveAs command and then I will edit the file name before saving to be Kristen013107(or something unique) before saving it so that it doesn't overwrite the original Kristen.doc base merge template. Likewise, is there a way after you save a file that is in a specified directory after it has been merged, to have this file moved and/or copied to another specified directory. Thanks in advance for any help! |
#8
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
File Names for MailMerge Documents
And you need to leave out this statement
ActiveDocument.Close if you want to have the opportunity to change the nme before saving. Peter Jamieson "Peter Jamieson" wrote in message ... You can use a macro like the following to perform the merge, but only if your mail merge main document does not have any Next record fields and similar stuff such as Next record if Peter Jamieson Sub ProduceOneDocPerSourceRec() ' ' NB, needs bettor error management and doubtless other things a VBA expert ' will point out. Dim intSourceRecord Dim objMerge As Word.MailMerge Dim strEman As String Dim strOutputDocumentName As String Dim TerminateMerge As Boolean ' Need to set up this object as the ActiveDocument changes when the ' merge is performed. Besides, it's clearer. Set objMerge = ActiveDocument.MailMerge With objMerge ' If no data source has been defined, do it here using OpenDataSource. ' But if it is already defined in the document, you should not need to define it here. ' .OpenDataSource _ ' Name:="whatever" intSourceRecord = 1 TerminateMerge = False Do Until TerminateMerge .DataSource.ActiveRecord = intSourceRecord ' if we have gone past the end (and possibly, if there are no records) ' then the Activerecord will not be what we have just tried to set it to If .DataSource.ActiveRecord intSourceRecord Then TerminateMerge = True ' the record exists Else ' while we are looking at the correct activerecord, ' create the document path name ' e.g. - you will need to change this - strEman = StrReverse(objMerge.Name) StrReverse(Mid(strEman, InStr(1, strEman & ".", ".") + 1)) strOutputDocumentName = _ "c:\mydoc\" & _ StrReverse(Mid(strEman, InStr(1, strEman & ".", ".") + 1)) & _ .DataSource.Datafields("CaseID").Value & ".doc" .DataSource.FirstRecord = intSourceRecord .DataSource.LastRecord = intSourceRecord .Destination = wdSendToNewDocument .Execute ' The Activedocument is always the output document ' Add any parameters you need to these calls ActiveDocument.SaveAs strOutputDocumentName ActiveDocument.Close intSourceRecord = intSourceRecord + 1 End If Loop End With End Sub "Kristen" wrote in message ... Hi Graham, I actually don't want version numbers because the document needs to have the result of a merged data field. Maybe it would be easier if I gave you an example. The merge document has a Case ID# in it called Case_ID. The name of the document is SoftwareNotice.doc. When the new document is created after the merge, when I go to Save it, I want it to look at the merge field Case_ID and name the document SoftwareNotice1234.doc, assuming that 1234 was the Case_ID. Does this make sense? Thanks for all of your help and prompt responses! "Graham Mayor" wrote: This sounds like you want to create 'versions' - see another macro on my web site at http://www.gmayor.com/save_numbered_versions.htm which could be adapted to your requirements -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Kristen wrote: Thanks for the link Graham. The problem is that this macro also splits the document into a new document for each record. Basically what I want is to have the new document named via a data line in the main document like this does, but not the other part with the splitting. Do you know where I can find how to do this. It seems like it should be a fairly common request. Thanks in advance! "Graham Mayor" wrote: The document doesn't have a name until it is saved Letter1 is simply Word's internal description. If you want individual merge letters named from the data - see http://www.gmayor.com/individual_merge_letters.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Kristen wrote: How do you save a new document generated from an existing MailMerge Template/Document as the same name as the original document/template rather than MS Word creating a new document with the merge info and calling it "Letter1." For example, if my original document with the merge fields in it is called Kristen when I select the merge function and the new document opens, I want it to default to the name Kristen.doc when I use the File-SaveAs command and then I will edit the file name before saving to be Kristen013107(or something unique) before saving it so that it doesn't overwrite the original Kristen.doc base merge template. Likewise, is there a way after you save a file that is in a specified directory after it has been merged, to have this file moved and/or copied to another specified directory. Thanks in advance for any help! |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Adding & removing file names from file menu | Microsoft Word Help | |||
Why do I get file permission errors when saving documents on USB . | Microsoft Word Help | |||
Unable to see full file name in Recently open documents on file me | New Users | |||
merge instructions from text file | Mailmerge | |||
File Names/hyperlinks in Master Documents referring to Subdocument | Microsoft Word Help |