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 / August 2005

Tip: Looking for answers? Try searching our database.

Splitter macro adds extra page

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark Y - 26 Aug 2005 15:38 GMT
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

Signature

www.familyfund.org.uk

Doug Robbins - 26 Aug 2005 18:08 GMT
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

Signature

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

> Hello all,
>
[quoted text clipped - 10 lines]
>
> Mark
Mark Y - 30 Aug 2005 10:29 GMT
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

-----------------------------------------------------------------------------

Signature

www.familyfund.org.uk

Doug Robbins - 30 Aug 2005 11:03 GMT
Try

   Target.Range.FormattedText=Letter.FormattedText

Signature

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

> Thanks for this. Have tried it out and it works, however, it removes all
> the
[quoted text clipped - 52 lines]
>
> -----------------------------------------------------------------------------
Mark Y - 30 Aug 2005 12:49 GMT
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

Signature

www.familyfund.org.uk

 
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.