Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: 21 Feb 2007 10:23:51 -0800,    group: microsoft.public.word.word97vba        back       


Difficulty with mail merge splitter   
I am using the following macro (from http://www.gmayor.com/individual_merge_letters.htm)
to attempt to split a large mail merge file.  The macro requires a
field to be added to the top of the merge letter on a line of its own.
When merged, the fieldnames will be the first line of the merged
letter. The macro then removes the line to restore each merge letter
to its required format during the splitting process.

My merge document often has three distinct sections to each "contact"
due to various headers/footers.  When I run this macro, it only splits
the first section of each letter.  Any ideas?


Sub SplitMergeLetter()
' splitter Macro modified to save individual letters with
' information from data source. The filename data must be added to
' the top of the merge letter - see web article.

Selection.EndKey Unit:=wdStory
Letters = Selection.Information(wdActiveEndSectionNumber)
Selection.HomeKey Unit:=wdStory
Counter = 1
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 = "D:\My Documents\Test\Merge\" & 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
date: 21 Feb 2007 10:23:51 -0800   author:   unknown

Re: Difficulty with mail merge splitter   
Try the following:

Dim arange As Range, Counter As Long
Selection.EndKey Unit:=wdStory
Letters = Selection.Information(wdActiveEndSectionNumber)
Selection.HomeKey Unit:=wdStory
Counter = 1
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 = "D:\My Documents\Test\Merge\" & sName & ".doc"
    With ActiveDocument
        Set arange = .Sections(1).Range
        arange.End = .Sections(3).Range.End
        arange.Cut
    End With
    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 + 2
    Application.ScreenUpdating = True
Wend

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

 wrote in message 
news:1172082231.755749.250710@j27g2000cwj.googlegroups.com...
>I am using the following macro (from 
>http://www.gmayor.com/individual_merge_letters.htm)
> to attempt to split a large mail merge file.  The macro requires a
> field to be added to the top of the merge letter on a line of its own.
> When merged, the fieldnames will be the first line of the merged
> letter. The macro then removes the line to restore each merge letter
> to its required format during the splitting process.
>
> My merge document often has three distinct sections to each "contact"
> due to various headers/footers.  When I run this macro, it only splits
> the first section of each letter.  Any ideas?
>
>
> Sub SplitMergeLetter()
> ' splitter Macro modified to save individual letters with
> ' information from data source. The filename data must be added to
> ' the top of the merge letter - see web article.
>
> Selection.EndKey Unit:=wdStory
> Letters = Selection.Information(wdActiveEndSectionNumber)
> Selection.HomeKey Unit:=wdStory
> Counter = 1
> 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 = "D:\My Documents\Test\Merge\" & 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
>
date: Thu, 22 Feb 2007 20:24:34 +0100   author:   Doug Robbins - Word MVP

Re: Difficulty with mail merge splitter   
test

"Doug Robbins - Word MVP"  wrote in message
news:uZpsgcrVHHA.1208@TK2MSFTNGP03.phx.gbl...
> Try the following:
>
> Dim arange As Range, Counter As Long
> Selection.EndKey Unit:=wdStory
> Letters = Selection.Information(wdActiveEndSectionNumber)
> Selection.HomeKey Unit:=wdStory
> Counter = 1
> 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 = "D:\My Documents\Test\Merge\" & sName & ".doc"
>     With ActiveDocument
>         Set arange = .Sections(1).Range
>         arange.End = .Sections(3).Range.End
>         arange.Cut
>     End With
>     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 + 2
>     Application.ScreenUpdating = True
> Wend
>
> -- 
> 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
>
>  wrote in message
> news:1172082231.755749.250710@j27g2000cwj.googlegroups.com...
> >I am using the following macro (from
> >http://www.gmayor.com/individual_merge_letters.htm)
> > to attempt to split a large mail merge file.  The macro requires a
> > field to be added to the top of the merge letter on a line of its own.
> > When merged, the fieldnames will be the first line of the merged
> > letter. The macro then removes the line to restore each merge letter
> > to its required format during the splitting process.
> >
> > My merge document often has three distinct sections to each "contact"
> > due to various headers/footers.  When I run this macro, it only splits
> > the first section of each letter.  Any ideas?
> >
> >
> > Sub SplitMergeLetter()
> > ' splitter Macro modified to save individual letters with
> > ' information from data source. The filename data must be added to
> > ' the top of the merge letter - see web article.
> >
> > Selection.EndKey Unit:=wdStory
> > Letters = Selection.Information(wdActiveEndSectionNumber)
> > Selection.HomeKey Unit:=wdStory
> > Counter = 1
> > 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 = "D:\My Documents\Test\Merge\" & 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
> >
>
>
date: Wed, 28 Feb 2007 14:44:10 -0500   author:   msnews.com

Re: Difficulty with mail merge splitter   
failed

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

"msnews.com"  wrote in message 
news:OA1rOC3WHHA.2284@TK2MSFTNGP03.phx.gbl...
> test
>
> "Doug Robbins - Word MVP"  wrote in message
> news:uZpsgcrVHHA.1208@TK2MSFTNGP03.phx.gbl...
>> Try the following:
>>
>> Dim arange As Range, Counter As Long
>> Selection.EndKey Unit:=wdStory
>> Letters = Selection.Information(wdActiveEndSectionNumber)
>> Selection.HomeKey Unit:=wdStory
>> Counter = 1
>> 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 = "D:\My Documents\Test\Merge\" & sName & ".doc"
>>     With ActiveDocument
>>         Set arange = .Sections(1).Range
>>         arange.End = .Sections(3).Range.End
>>         arange.Cut
>>     End With
>>     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 + 2
>>     Application.ScreenUpdating = True
>> Wend
>>
>> -- 
>> 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
>>
>>  wrote in message
>> news:1172082231.755749.250710@j27g2000cwj.googlegroups.com...
>> >I am using the following macro (from
>> >http://www.gmayor.com/individual_merge_letters.htm)
>> > to attempt to split a large mail merge file.  The macro requires a
>> > field to be added to the top of the merge letter on a line of its own.
>> > When merged, the fieldnames will be the first line of the merged
>> > letter. The macro then removes the line to restore each merge letter
>> > to its required format during the splitting process.
>> >
>> > My merge document often has three distinct sections to each "contact"
>> > due to various headers/footers.  When I run this macro, it only splits
>> > the first section of each letter.  Any ideas?
>> >
>> >
>> > Sub SplitMergeLetter()
>> > ' splitter Macro modified to save individual letters with
>> > ' information from data source. The filename data must be added to
>> > ' the top of the merge letter - see web article.
>> >
>> > Selection.EndKey Unit:=wdStory
>> > Letters = Selection.Information(wdActiveEndSectionNumber)
>> > Selection.HomeKey Unit:=wdStory
>> > Counter = 1
>> > 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 = "D:\My Documents\Test\Merge\" & 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
>> >
>>
>>
>
>
date: Wed, 28 Feb 2007 22:08:09 +0100   author:   Doug Robbins - Word MVP

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us