Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 07-30-2019, 09:27 AM
gmaxey gmaxey is offline Populating multiple Content Controls after mail merge Windows 10 Populating multiple Content Controls after mail merge Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

You could put your header merge field in a richtext CC titled "Ref"

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oSec As Section
Dim oCC As ContentControl, oCC2 As ContentControl
  For Each oSec In ActiveDocument.Sections
    Set oCC = oSec.Headers(wdHeaderFooterPrimary).Range.ContentControls(1)
    For Each oCC2 In oSec.Range.ContentControls
      If oCC2.Title = "ref_no" Then
       oCC2.Range.Text = oCC.Range.Text
       'If there is only one "ref_no" CC per section then:
       'Exit For
      End If
    Next
  Next
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Populating multiple Content Controls after mail merge Populating Tables with data when available only - Using Mail merge stevejohhnym Mail Merge 1 06-25-2019 12:50 AM
Populating multiple Content Controls after mail merge Delete or merge Content controls with the same name sylvio Word VBA 9 08-30-2017 01:46 AM
Macro to save docx to doc that checks compatibility and converts content controls to static content. staicumihai Word VBA 4 10-12-2016 08:23 PM
Populating multiple Content Controls after mail merge Inserting multiple content controls for a date jeffreybrown Word 2 05-09-2016 05:53 PM
Mail Merge Field Not Populating JennEx Mail Merge 3 05-10-2015 09:30 PM

Other Forums: Access Forums

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