Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-06-2013, 04:51 PM
macropod's Avatar
macropod macropod is offline Mailmerge to Email with a mailmerge attachment Windows 7 64bit Mailmerge to Email with a mailmerge attachment Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,512
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default


Both your Word document and the pdf would take a fair bit of effort to convert to a Word document that doesn't use textboxes/frames. Try the following:
Code:
Sub SplitMergeForm()
    'Application.ScreenUpdating = False
     '
     ' 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, docName As String
    Dim oDoc As Document, oNewDoc As Document
    Dim Rng As Range
    Dim i As Long, j As Long
    Set oDoc = ActiveDocument
    With oDoc
        j = .Sections.Count - 1
        For i = 1 To j Step 2
            Set Rng = .Sections(i).Range.Paragraphs.Last.Range
            With Rng
                .End = .End - 1
                sName = Replace(.Text, ".", "_")
                .Delete
                .Start = .Sections.First.Range.Start
                docName = "C:\Our Folders\IMAP\Form " & sName & ".doc"
                .MoveEnd wdSection, 2
                .Copy
            End With
            Set oNewDoc = Documents.Add
            With oNewDoc
                With .Range
                    .Paste
                    .ParagraphFormat.SpaceBefore = 0
                    .ParagraphFormat.SpaceAfter = 0
                End With
                .SaveAs2 FileName:=docName, FileFormat:=wdFormatPDF, AddToRecentFiles:=False
                .Close wdDoNotSaveChanges
            End With
        Next
        .Close wdDoNotSaveChanges
    End With
Application.ScreenUpdating = True
End Sub
Each output document will have an empty extra last page, but that's unavoidable unless you create a template that preserves the page layout, for calling via the Documents.Add process.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

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 02:41 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