Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Splitter macro adds extra page
Hello all,
I'm using Doug Robbins/Graham Mayors splitter macro to merge to 6,000 individual files. It works fine (thank you guys).....but....at the end of each document produced there is a blank page. Each doc is 6 pages which prints out double sided on 3 sheets, when the macro is run an additional page is added making it print out onto 4 pages with the last one being blank. Any suggestions as to why this may be and any solutions out there? Thanks in advance Mark -- www.familyfund.org.uk |
#2
|
|||
|
|||
This is a later version of my macro than the one on Graham's site that I
think overcomes the problem that you mention. Sub splitter() ' splitter Macro ' Macro created by Doug Robbins to save each letter created by a mailmerge as a separate file. Dim i As Long, Source as Document, Target as Document, Letter as Range Set Source = ActiveDocument For i = 1 to Source.Sections.Count Set Letter = Source.Sections(i).Range Letter.End=Letter.End-1 Set Target = Documents.Add Target.Range=Letter Target.SaveAs FileName:="Letter" & i Target.Close Next i End Sub If you do not need to save the documents individually, but just want to print the individually, use the following: Dim i As Long With ActiveDocument For i = 1 To .Sections.Count .PrintOut Range:=wdPrintFromTo, From:="s" & i, To:="s" & i Next i End With -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Mark Y via OfficeKB.com" wrote in message ... Hello all, I'm using Doug Robbins/Graham Mayors splitter macro to merge to 6,000 individual files. It works fine (thank you guys).....but....at the end of each document produced there is a blank page. Each doc is 6 pages which prints out double sided on 3 sheets, when the macro is run an additional page is added making it print out onto 4 pages with the last one being blank. Any suggestions as to why this may be and any solutions out there? Thanks in advance Mark -- www.familyfund.org.uk |
#3
|
|||
|
|||
Thanks for this. Have tried it out and it works, however, it removes all the
formatting from the doc (it's laid out in tables). The original macro I was using is the one below - this works perfectly apart from adding that extra page at the end are there any solutions or maods that I can make to this for removing the extra page. Thanks again for all the help! Best Mark --------------------------------------------------------------------- Sub SplitMerge() ' splitter Macro ' Macro created 16-08-98 by Doug Robbins to save each letter created by a ' mailmerge as a separate file. ' with modifications by Graham Mayor 16-06-03 Dim Title As String Dim Default As String Dim MyText As String Dim MyName As Variant Dim MyPath As String Selection.EndKey Unit:=wdStory Letters = Selection.Information(wdActiveEndSectionNumber) Selection.HomeKey Unit:=wdStory Counter = 1 MyPath = "U:\1A_currentFFprojects\Cohort\COHORTmerge" Default = "Merged" MyText = "Enter a filename. Long filenames may be used." Title = "File Name" MyName = InputBox(MyText, Title, Default) If MyName = "" Then End End If While Counter Letters Application.ScreenUpdating = False Docname = MyPath & LTrim$(Str$(Counter)) & " " & MyName ActiveDocument.Sections.First.Range.Cut Documents.Add Selection.Paste ActiveDocument.SaveAs FileName:=Docname ActiveWindow.Close Counter = Counter + 1 Application.ScreenUpdating = True Wend End Sub ----------------------------------------------------------------------------- -- www.familyfund.org.uk Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...merge/200508/1 |
#4
|
|||
|
|||
Try
Target.Range.FormattedText=Letter.FormattedText -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Mark Y via OfficeKB.com" wrote in message ... Thanks for this. Have tried it out and it works, however, it removes all the formatting from the doc (it's laid out in tables). The original macro I was using is the one below - this works perfectly apart from adding that extra page at the end are there any solutions or maods that I can make to this for removing the extra page. Thanks again for all the help! Best Mark --------------------------------------------------------------------- Sub SplitMerge() ' splitter Macro ' Macro created 16-08-98 by Doug Robbins to save each letter created by a ' mailmerge as a separate file. ' with modifications by Graham Mayor 16-06-03 Dim Title As String Dim Default As String Dim MyText As String Dim MyName As Variant Dim MyPath As String Selection.EndKey Unit:=wdStory Letters = Selection.Information(wdActiveEndSectionNumber) Selection.HomeKey Unit:=wdStory Counter = 1 MyPath = "U:\1A_currentFFprojects\Cohort\COHORTmerge" Default = "Merged" MyText = "Enter a filename. Long filenames may be used." Title = "File Name" MyName = InputBox(MyText, Title, Default) If MyName = "" Then End End If While Counter Letters Application.ScreenUpdating = False Docname = MyPath & LTrim$(Str$(Counter)) & " " & MyName ActiveDocument.Sections.First.Range.Cut Documents.Add Selection.Paste ActiveDocument.SaveAs FileName:=Docname ActiveWindow.Close Counter = Counter + 1 Application.ScreenUpdating = True Wend End Sub ----------------------------------------------------------------------------- -- www.familyfund.org.uk Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...merge/200508/1 |
#5
|
|||
|
|||
Doug,
Many thanks for your help this works brilliantly. For info I am using this: ------------------------------------------------------------------------------ ----------------- Sub splitter() ' splitter Macro ' Macro created by Doug Robbins to save each letter created by a mailmerge ' as a separate file. Dim i As Long, Source as Document, Target as Document, Letter as Range Set Source = ActiveDocument For i = 1 to Source.Sections.Count Set Letter = Source.Sections(i).Range Letter.End=Letter.End-1 Set Target = Documents.Add Target.Range.FormattedText=Letter.FormattedText Target.SaveAs FileName:="Letter" & i Target.Close Next i End Sub ------------------------------------------------------------------------- I had to modify my page layout slightly e.g adjust some of the margins and headers and footers so that the formatted text and tables fitted as I needed. Also took my merge field out of the header and put it in the body. Many many thanks as this has been bugging me for weeks! Mark -- www.familyfund.org.uk Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...merge/200508/1 |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to select whole page | Microsoft Word Help | |||
section breaks change each time opening document | Microsoft Word Help | |||
Why do I get an extra page with a Section Break (next page)? | Page Layout | |||
How to set a macro to insert a second page into a template | Microsoft Word Help | |||
Insert objects at page breaks | Microsoft Word Help |