P
Parisa
I found this macro and it works FOR ME which is surprising but I need help in
modifying it. Right now it assigns the date and a numbered index at the end
of the filename. I have bookmarks and reference fields in mail merge
document. Is there a way I can use the data from my reference fields {ref
companynumber},{ref company}as the unique filename for each new document.
122366,ABC Company
156336,NYC Company
236993,Microsoft Company
If references won't work. I can use bookmarks instead.
Thanks
Location where macro was found
http://www.gmayor.com/individual_merge_letters.htm
The macro assigned
Sub Splitter()
' splitter Macro
' Macro created 16-08-98 by Doug Robbins to save each letter created by a
' mailmerge as a separate file.
' With minor modifications by Graham Mayor 10-02-03
Dim mask As String
Selection.EndKey Unit:=wdStory
Letters = Selection.Information(wdActiveEndSectionNumber)
mask = "ddMMyy"
Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter < Letters
DocName = "c:\DOCUMENTS\" & Format(Date, mask) & " " & LTrim$(Str$(Counter))
ActiveDocument.Sections.First.Range.Cut
Documents.add
With Selection
.Paste
.EndKey Unit:=wdStory
.MoveLeft Unit:=wdCharacter, Count:=1
.Delete Unit:=wdCharacter, Count:=1
End With
ActiveDocument.SaveAs FileName:=DocName, FileFormat:=wdFormatDocument
ActiveWindow.Close
Counter = Counter + 1
Wend
End Sub
modifying it. Right now it assigns the date and a numbered index at the end
of the filename. I have bookmarks and reference fields in mail merge
document. Is there a way I can use the data from my reference fields {ref
companynumber},{ref company}as the unique filename for each new document.
122366,ABC Company
156336,NYC Company
236993,Microsoft Company
If references won't work. I can use bookmarks instead.
Thanks
Location where macro was found
http://www.gmayor.com/individual_merge_letters.htm
The macro assigned
Sub Splitter()
' splitter Macro
' Macro created 16-08-98 by Doug Robbins to save each letter created by a
' mailmerge as a separate file.
' With minor modifications by Graham Mayor 10-02-03
Dim mask As String
Selection.EndKey Unit:=wdStory
Letters = Selection.Information(wdActiveEndSectionNumber)
mask = "ddMMyy"
Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter < Letters
DocName = "c:\DOCUMENTS\" & Format(Date, mask) & " " & LTrim$(Str$(Counter))
ActiveDocument.Sections.First.Range.Cut
Documents.add
With Selection
.Paste
.EndKey Unit:=wdStory
.MoveLeft Unit:=wdCharacter, Count:=1
.Delete Unit:=wdCharacter, Count:=1
End With
ActiveDocument.SaveAs FileName:=DocName, FileFormat:=wdFormatDocument
ActiveWindow.Close
Counter = Counter + 1
Wend
End Sub