Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-11-2013, 09:41 AM
Baldeagle Baldeagle is offline Mailmerge to Email with a mailmerge attachment Windows XP Mailmerge to Email with a mailmerge attachment Office 2007
Advanced Beginner
Mailmerge to Email with a mailmerge attachment
 
Join Date: Apr 2012
Posts: 62
Baldeagle is on a distinguished road
Default Mailmerge to Email with a mailmerge attachment

I got help last May on this subject and the result was successful. I am now trying something similar but different. The following is the Macro which I used previously but this time it says that there is a problem at the section highlighted in red. The only difference that I can see is that my merged documents have 2 pages each whereas last year there was only one. Is this the cause of my problem and if so how do I modify the Macro to keep the 2 pages together when it does the split?


Code:
Sub SplitMergeForm() 
     '
     ' SplitMergeForm Macro
     '
     ' splitter Macro modified to save individual Gift Aid (and Tax) Allocation Forms with
     
     ' information from data source. The filename data must be added to     
     ' the top of the merge letter - see web article.     
    Dim sName As String 
    Dim docName As String 
    Dim Letters As String 
    Dim Counter As Long 
    Dim oDoc As Document 
    Dim oNewDoc As Document 
    Set oDoc = ActiveDocument 
    oDoc.Save      
    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 = "C:\Our Folders\IMAP\Form " & sName & ".doc"          
        oDoc.Sections.First.Range.Cut 
        Set oNewDoc = 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 
        oNewDoc.SaveAs FileName:=docName, _ 
        FileFormat:=wdFormatDocument, _ 
        AddToRecentFiles:=False 
        ActiveWindow.Close 
        Counter = Counter + 1 
        Application.ScreenUpdating = True 
    Wend      
    oDoc.Close wdDoNotSaveChanges      
End Sub

Last edited by macropod; 02-05-2013 at 08:21 PM. Reason: Added code tags & formatting
Reply With Quote
 

Tags
attachments, email



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mailmerge to Email with a mailmerge attachment Mailmerge to email as attachments j_Southern Mail Merge 12 03-03-2021 07:57 AM
Mailmerge to Email with a mailmerge attachment Mailmerge to email awstyle Mail Merge 1 05-31-2012 08:13 AM
Mailmerge to Email with a mailmerge attachment Mailmerge to Email with a mailmerge attachment Baldeagle Mail Merge 13 05-29-2012 02:04 PM
Mailmerge to Email with a mailmerge attachment Email from MailMerge Baldeagle Mail Merge 4 04-06-2012 05:46 AM
Mailmerge to Email with a mailmerge attachment How do you add text to email mailmerge? DerekScambler Mail Merge 10 04-19-2011 05:30 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:22 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