Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-30-2019, 07:16 PM
DM2 DM2 is offline Mail Merge with Merged File Name in Footer Windows 7 64bit Mail Merge with Merged File Name in Footer Office 2010
Novice
Mail Merge with Merged File Name in Footer
 
Join Date: Apr 2019
Posts: 5
DM2 is on a distinguished road
Default Mail Merge with Merged File Name in Footer

We often have a need to create cover pages for technical documents submitted to clients. Mail Merge to a PDF seems to be the simplest solution. I've read several posts on the subject:

But ended up using a AddIn from "Greg Mayor" (http://www.gmayor.com/individual_merge_letters.htm) as it has provided me the a "best fit" solution.

The AddIn permits me to "...run a macro before saving the documents..." with a caveat that...
Quote:
In order to ensure that macros applied to this process actually run on the document they must pass a document parameter to the macro e.g. Sub MacroName(oDoc as Document). The variable name itself does not matter. In the following code example, a ® characters are formatted with the Segoe UI font and are superscripted. (The sample document includes such characters so that you may evaluate the results).
...and provides the below example:
Code:
Sub FormatTM(oDoc As Document)
     Dim oRng As Range
     Set oRng = oDoc.Range
     With oRng.Find
          Do While .Execute(FindText:=ChrW(174))
               With oRng.Font
                    .name = "Segoe UI"
                    .Superscript = True
               End With
          Loop
     End With
End Sub
Doug Robbins (Word MVP) offered some code to do this (https://answers.microsoft.com/en-us/...f-e67f916252f9), which I've highlighted in red below (with my additions in Blue, and the additional requirements from Greg Mayor, in Green):

Code:
Sub FooterTx()(oDoc As Document)
    Dim i As Long, Source As Document, Target As Document, Letter As Range
    Dim fname As Range
    Set Source = ActiveDocument
    With Source
        For i = 1 To .Sections.Count
            Set fname = .Sections(i).Footers(wdHeaderFooterPrimary).Range
            fname.End = fname.End - 1
            Set Letter = .Sections(i).Range
            Letter.End = Letter.End - 1
            Set Target = Documents.Add
            With Target
                .Range.FormattedText = Letter.FormattedText
                .Sections(1).Footers(wdHeaderFooterPrimary).Range.Text = ""
                .SaveAs FileName:=fname.Text & " - Contributions", FileFormat:=wdFormatPDF
                .Close wdDoNotSaveChanges
            End With
        Next i
    End With
End Sub
I know I'm missing the setting the variable "Odoc", but i'm not sure where to place it in the macro.

Doug Robbins code by itself works for me, but not in the Addit.

Anyone's help would be appreciated.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
showing mail merge all in one file lezawang Mail Merge 3 05-24-2018 03:10 PM
Mail Merge with Merged File Name in Footer Log file for mail merge neilclelland Mail Merge 7 12-08-2016 03:08 PM
some records disappear after emailing mail merged file Dr Ennui Mail Merge 1 06-10-2015 04:17 PM
Mail Merge with Merged File Name in Footer Mail Merge is Deleting objects in my header and footer during the merge bgranzow Mail Merge 9 06-05-2015 05:03 AM
Mail Merge with Merged File Name in Footer how do i ad a specific pdf file to a mail merge? mseibel Mail Merge 1 08-28-2012 07:53 PM

Other Forums: Access Forums

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