Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / January 2005

Tip: Looking for answers? Try searching our database.

kulchic723@hotmail.com

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jessica - 10 Jan 2005 00:27 GMT
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,
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.