Hello,
I am not very familiar with visual basic and am trying to use the macro that
separates a large merged mail merge document into saved separate documents.
It keeps telling me I have an invalid file name.
Can anyone please help.
This is the macro I am using.
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 = "D:\My Documents\Temp\Workgroup\" & 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
And when I run debug it takes me to the ActiveDocument.SaveAs FileName: line
Please let me know.
Thank you,
Doug Robbins - 12 Jan 2005 03:37 GMT
The following should all be on one line:
DocName = "D:\My Documents\Temp\Workgroup\" & Format(Date, mask) & " " &
LTrim$(Str$(Counter))

Signature
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.
Hope this helps,
Doug Robbins - Word MVP
> Hello,
>
[quoted text clipped - 46 lines]
>
> Thank you,