View Single Post
 
Old 10-20-2023, 08:08 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,158
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

There is a better way to do this - put mapped Content Controls in the document where you want that data to be displayed. You can then either read or write to the first instance of each CC in the document to interact with the vba userform.

There are quite elegant templates to help with content controls (created by Greg Maxey and Graham Mayor which can be very useful if you are struggling with some of the concepts.

If you add a few content controls to your first template and set them to be mapped to built-in properties then you can paste these into the other templates at the relevant locations. You can then include code to read/write to the CCs OR to the document properties. eg
Code:
Sub DocProps()
  Dim aCC As ContentControl
  For Each aCC In ActiveDocument.ContentControls
    aCC.Range.Text = aCC.Title
    If aCC.XMLMapping.IsMapped Then
      aCC.Tag = aCC.XMLMapping.XPath
    End If
  Next aCC
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote