Splitting Mail Merged Documents in Word using Macro code?

Sheils
Sheils used Ask the Experts™
on
an anyone tell me how to write - using text - a macro in word - I have code that will split a mail merge into individual docs but don't know how to use it?


Sub Splitter()
    Selection.EndKey Unit:=wdStory
    numlets = Selection.Information(wdActiveEndSectionNumber)
    If numlets > 1 Then numlets = numlets - 1
    Selection.HomeKey Unit:=wdStory
    BaseName = "c:\Let"
    For Counter = 1 To numlets
        DocName = BaseName & Right("000" & LTrim(Str(Counter)), 3)
        ActiveDocument.Sections.First.Range.Cut
        Documents.Add
        Selection.Paste
        Selection.MoveLeft Unit:=wdCharacter, Count:=1
        Selection.Delete Unit:=wdCharacter, Count:=1
        ActiveDocument.SaveAs FileName:=DocName
        ActiveWindow.Close
    Next Counter
End Sub

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
MIS Liason
Most Valuable Expert 2012
Commented:
First there are no declarations in this code.

When I finally put some in and ran this on a merged document, the merge got trashed!
:-O

I suggest that you add the Word Zone to this question.

Perhaps an expert in the Word zone has seen, or used this code and can tell us what we are doing wrong...
;-)

Jeff

Author

Commented:
Jeff

My apology. This is a question that a friend of mine was working on. I believe that she has already sorted it out. Sorry for wasting your time

Regards

SB9
Jeffrey CoachmanMIS Liason
Most Valuable Expert 2012

Commented:
No waste of time.

I thought it was an interesting question.

If you post the solution you can ask that your own answer be accepted instead of mine.
I am interested in the resolution.
(Remember, I don't need the points)
;-)

Besides, my post was not a solution, so I don't deserve any points anyway...

;-)

Jeff

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial