Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-26-2009, 02:32 AM
ahmed_tr ahmed_tr is offline individual merge letters Windows 7 individual merge letters Office 2007
Novice
individual merge letters
 
Join Date: Jun 2009
Posts: 2
ahmed_tr is on a distinguished road
Exclamation individual merge letters

First of all
Hi to all members and I am glad that I found a forum that could help me out solve some problems that i face with office.
I just found out by googling a code to separate docs by individual and naming the files from the data source.

the code that i founded is this:

PHP Code:

                        Sub SplitMergeLetter
()
        
' splitter Macro modified to save individual          letters with 
                  ' 
information from          data sourceThe 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
             '
Documents          are based on the Normal template
                               
'To use an alternative template follow the link.
                     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 
I found the code very useful except the problem that I have is that gives me a blank second page for every doc created.

Any kind of help is appriciated.
Thanks
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
individual merge letters sending personal letters misteroffice Word 3 12-23-2008 08:51 AM
Stop individual emails from being archived. saltydog85 Outlook 0 07-06-2007 02:13 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:36 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft