View Single Post
 
Old 07-03-2011, 11:05 PM
socrates01 socrates01 is offline Windows Vista Office 2007
Novice
 
Join Date: Jul 2011
Posts: 2
socrates01 is on a distinguished road
Default NEED macro to save word doc as pdf

Hi guys,

I run a mail merge on a regular basis the output of which is a work document that has over 2000 pages. i use the below macro to split out the pages and save them into individual documents. What i really need as the end product is a set of individual pdf documents off the back of the mail merge. is there a way to to do this directly in the mail merge or alternatively can anyone help me in modifying the below macro so that when it splits the pages up it automatically saves the individual documents as pdf's.
Code:
Sub Splitter()
    Selection.EndKey Unit:=wdStory
    numlets = Selection.Information(wdActiveEndSectionNumber)
    If numlets > 1 Then numlets = numlets - 1
    Selection.HomeKey Unit:=wdStory
    BaseName = "D:\Documents and Settings\Desktop\Test mail merge\XXX"
    For Counter = 1 To numlets
        DocName = BaseName & Right("0" & LTrim(Str(Counter)), 10)
        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
Any help would be much appreciated

Thanks,
XXX
Reply With Quote