[Solved] Graph portion of Excel table in Word with a macro


go back to the beginning

insert a document variable in a new word document using following sequence (word 2016)

insert tab … text … quick parts … field … categories: document automation … field names: docVariable … put in variable name xxxx

then run this code

Sub aaa()

    'ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes  ' toggle field code view
    Stop
    ActiveWindow.View.ShowFieldCodes = True
    Stop
    ActiveWindow.View.ShowFieldCodes = False

    ActiveDocument.Variables("xxxx").Value = "abc123"
    ActiveDocument.Range.Fields.Update

    Stop

    ActiveDocument.Variables("xxxx") = "xyz987"
    ActiveDocument.Fields.Update

End Sub

if that works, then use the code with the document that you are having trouble with and figure out if your field names are what you think they are

solved Graph portion of Excel table in Word with a macro