View Single Post
 
Old 07-30-2019, 09:27 AM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,598
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