View Single Post
 
Old 06-06-2019, 04:42 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

Perhaps as a single macro:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim Rng As Range
With ActiveDocument.Sections.First.Headers(wdHeaderFooterPrimary).Range.Tables(1).Cell(1, 3)
  Set Rng = .Range
  Rng.Text = vbNullString
  Rng.End = Rng.End - 1
  .Range.Fields.Add Rng, wdFieldEmpty, "MERGEFIELD Address_PostCode", False
  Rng.Characters.Last.InsertBefore " "
  .Range.Fields.Add Rng, wdFieldEmpty, "MERGEFIELD Address_line4", False
  Rng.Characters.Last.InsertBefore Chr(11)
  .Range.Fields.Add Rng, wdFieldEmpty, "MERGEFIELD Address_line3", False
  Rng.Characters.Last.InsertBefore Chr(11)
  .Range.Fields.Add Rng, wdFieldEmpty, "MERGEFIELD Address_line2", False
  Rng.Characters.Last.InsertBefore Chr(11)
  .Range.Fields.Add Rng, wdFieldEmpty, "MERGEFIELD Address_line1", False
End With
Application.ScreenUpdating = True
End Sub
As coded, the macro assumes the mergefields go in cell C1 of the table.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote