Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
owen owen is offline
external usenet poster
 
Posts: 61
Default Modified SplitMerge added page

I combined parts and modified the SplitMerge macros on site hosted by gmayor
(many thanks to graham and Doug Robbins); to name the split docs with unique
name from mergfield in doc and save to selected location. It works fine
except it creates an extra blank page with each letter, does any one know
what I need to change or add to keep the extra page from being created, or to
automatically delete it.

thanks,
owen

Here is the Macro as written:

Sub SplitMergeDocWithName()

' SplitMergeDoc Macro modified to save individual letters with
' information from data source. The filename data must be added to
' the top of the merge letter and must be unique.

Dim Default As String
Dim MyPath As String
Selection.EndKey Unit:=wdStory
Letters = Selection.Information(wdActiveEndSectionNumber)
Selection.HomeKey Unit:=wdStory
Counter = 1
Default = ""
Title = "Save To"
MyText = "Enter File Location"
MyPath = InputBox(MyText, Title, Default)
If MyPath = "" Then
End
End If
While Counter Letters
Application.ScreenUpdating = False
With Selection
.HomeKey Unit:=wdStory
.EndKey Unit:=wdLine, Extend:=wdExtend
.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
End With
sName = Selection
Docname = MyPath & sName & ".doc"
ActiveDocument.Sections.First.Range.Cut
Documents.Add
With Selection
.Paste
.HomeKey Unit:=wdStory
.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
.Delete
End With
ActiveDocument.SaveAs FileName:=Docname, FileFormat:=wdFormatDocument
ActiveWindow.Close
Counter = Counter + 1
Application.ScreenUpdating = True
Wend


End Sub

  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Modified SplitMerge added page

In the following macro, the blank page is eliminated by converting the
section break to a continuous section break

Sub splitter()
' splitter Macro
' Macro created by Doug Robbins to save each letter created by a mailmerge
' as a separate file, retaining the header and footer information.
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
Set Target = Documents.Add
Target.Range = Letter
Target.Sections(2).PageSetup.SectionStart = wdSectionContinuous
Target.SaveAs FileName:="Letter" & i
Target.Close
Next i
End Sub


--
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

"owen" wrote in message
...
I combined parts and modified the SplitMerge macros on site hosted by
gmayor
(many thanks to graham and Doug Robbins); to name the split docs with
unique
name from mergfield in doc and save to selected location. It works fine
except it creates an extra blank page with each letter, does any one know
what I need to change or add to keep the extra page from being created, or
to
automatically delete it.

thanks,
owen

Here is the Macro as written:

Sub SplitMergeDocWithName()

' SplitMergeDoc Macro modified to save individual letters with
' information from data source. The filename data must be added to
' the top of the merge letter and must be unique.

Dim Default As String
Dim MyPath As String
Selection.EndKey Unit:=wdStory
Letters = Selection.Information(wdActiveEndSectionNumber)
Selection.HomeKey Unit:=wdStory
Counter = 1
Default = ""
Title = "Save To"
MyText = "Enter File Location"
MyPath = InputBox(MyText, Title, Default)
If MyPath = "" Then
End
End If
While Counter Letters
Application.ScreenUpdating = False
With Selection
.HomeKey Unit:=wdStory
.EndKey Unit:=wdLine, Extend:=wdExtend
.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
End With
sName = Selection
Docname = MyPath & sName & ".doc"
ActiveDocument.Sections.First.Range.Cut
Documents.Add
With Selection
.Paste
.HomeKey Unit:=wdStory
.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
.Delete
End With
ActiveDocument.SaveAs FileName:=Docname, FileFormat:=wdFormatDocument
ActiveWindow.Close
Counter = Counter + 1
Application.ScreenUpdating = True
Wend


End Sub



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
How to open a word doc to last modified page... roger_27 Microsoft Word Help 3 March 8th 07 10:40 PM
Problem arises when ref bookmark is added in the header ,it does not take the modified values and displays the same old values divya Microsoft Word Help 2 July 6th 06 01:08 PM
Problem arises when ref bookmark is added in the header ,it does not take the modified values and displays the same old values divya Microsoft Word Help 0 July 6th 06 11:47 AM
title page being added to page total Nimbus55 Microsoft Word Help 2 August 3rd 05 12:07 AM
can the web page wizard be added to office2003 morningcoffee5200 Microsoft Word Help 1 June 5th 05 02:33 PM


All times are GMT +1. The time now is 07:49 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"