Reply
 
Thread Tools Display Modes
  #1   Report Post  
Mark Y via OfficeKB.com
 
Posts: n/a
Default 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   Report Post  
Doug Robbins
 
Posts: n/a
Default

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   Report Post  
Mark Y via OfficeKB.com
 
Posts: n/a
Default

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   Report Post  
Doug Robbins
 
Posts: n/a
Default

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   Report Post  
Mark Y via OfficeKB.com
 
Posts: n/a
Default

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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to select whole page TudorDoc Microsoft Word Help 0 June 24th 05 05:10 PM
section breaks change each time opening document Dave Microsoft Word Help 6 March 21st 05 11:01 AM
Why do I get an extra page with a Section Break (next page)? Section Break Extra Page Page Layout 1 March 14th 05 11:38 PM
How to set a macro to insert a second page into a template A. Richardson Microsoft Word Help 5 November 30th 04 10:31 AM
Insert objects at page breaks DRS - Jonathan Microsoft Word Help 4 November 29th 04 07:16 PM


All times are GMT +1. The time now is 02:27 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"