I am using a DocVariable to insert data into a header.
My DocVariable field looks like
{ DOCVARIABLE Subject \ *MERGEDFORMAT }
And the code I am using is
Option Explicit

Private Sub CommandButton1_Click()
' Prevent variable from being deleted
    If txtSubject = "" Then txtSubject = " "
    ActiveDocument.Variables("Subject") = txtSubject
    If txtInfo = "" Then txtInfo = " "
    ActiveDocument.Variables("Info") = txtInfo
    ' Update fields in document
    ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Fields.Update
    Unload Me
End Sub

Private Sub UserForm_Initialize()
' Load variables into text boxes
    On Error Resume Next
    txtSubject = ActiveDocument.Variables("Subject")
    txtInfo = ActiveDocument.Variables("Info")
End Sub
It works, but the problem I have noticed was that if I reopen document to continue working and do not make any changes to my variable fields (using code) if I were to select print preview I would then get a bunch of gibberish added to the variable fields.
any thoughts or suggestions would be greatly appreciated