Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-01-2018, 07:39 AM
RMerckling RMerckling is offline Update & Unlink Specific Merge Field in Word Doc from Mail Merge - Excel VBA Windows 7 64bit Update & Unlink Specific Merge Field in Word Doc from Mail Merge - Excel VBA Office 2010 32bit
Novice
Update & Unlink Specific Merge Field in Word Doc from Mail Merge - Excel VBA
 
Join Date: Jan 2018
Posts: 29
RMerckling is on a distinguished road
Default Update & Unlink Specific Merge Field in Word Doc from Mail Merge - Excel VBA

Hey all,



Currently, I have some code that runs a mail merge from my Excel Workbook to a Word Doc. The code also selects all within the Word Doc, updates the fields and then unlinks them from the mail merge.

Code:
    strWorkbookName = ThisWorkbook.Path & "\" & ThisWorkbook.Name
    Worksheets("Data").Activate
       
    'Opens New Plan Doc Template
    Set appWD = CreateObject("Word.Application")
    appWD.Visible = True

    appWD.Documents.Open Filename:=PlanDocTemplate
    
    ActiveDocument.MailMerge.OpenDataSource Name:=strWorkbookName, _
    Format:=wdMergeInfoFromExcelDDE, _
    ConfirmConversions:=True, _
    ReadOnly:=False, _
    LinkToSource:=True, _
    AddToRecentFiles:=False, _
    PasswordDocument:="", _
    PasswordTemplate:="", _
    Revert:=False, _
    Connection:="Entire Spreadsheet", _
    SQLStatement:="SELECT * FROM `Data$`", _
    SQLStatement1:="", _
    SubType:=wdMergeSubTypeOther
    
    appWD.Visible = True
   
    appWD.Selection.WholeStory
    appWD.Selection.Fields.Update
    appWD.Selection.Fields.Unlink
    'New Code Here to update & unlink <<footer>> merge field
    ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument
    appWD.ActiveDocument.Save
This works great for now, but the footer of the word doc also has a merge field "<<footer>>" which doesn't get selected through the code, appWD.Selection.WholeStory. I'm imagining there's a way to select the entire footer and appWD.Selection.Fields.Update & .Unlink but then that would capture the automated page number at the bottom and leave it static, which I wouldn't want. I.E. every page number at the bottom would be Page 1, Page 1, Page 1...

Is there a way to tell Excel VBA to update and unlink the individual merge field "<<footer>>" only?

Thanks all,
Rich
Reply With Quote
 

Tags
excel vba, mail merge, word vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Update &amp; Unlink Specific Merge Field in Word Doc from Mail Merge - Excel VBA How do I mail merge records into table columns with more than one merge field? tech123 Mail Merge 1 04-26-2017 07:13 PM
Mail merge how to link mail merge field value to a column heading dsummers Mail Merge 1 05-08-2014 02:59 PM
Update &amp; Unlink Specific Merge Field in Word Doc from Mail Merge - Excel VBA Mail Merge a Listing grouped by specific field KarenLS Mail Merge 1 11-11-2012 02:41 PM
Update &amp; Unlink Specific Merge Field in Word Doc from Mail Merge - Excel VBA Mail Merge: cannot display the field in Excel correctly derricklo1980 Mail Merge 5 08-16-2012 07:15 PM
Update &amp; Unlink Specific Merge Field in Word Doc from Mail Merge - Excel VBA Mail Merge: cannot display the field in Excel correctly derricklo1980 Excel 1 08-16-2012 12:51 AM

Other Forums: Access Forums

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