View Single Post
 
Old 10-28-2022, 06:24 PM
BrianHoard BrianHoard is offline Windows 10 Office 2019
Advanced Beginner
 
Join Date: Jul 2022
Location: Haymarket, VA USA
Posts: 85
BrianHoard is on a distinguished road
Default

Hi,
Are you asking if you can save a variable in a document?
If so, I was looking into that a while ago, and although haven't used it yet, I did record the following notes on how to store a document variable, and retrieve it again.
Hopefully this helps get you on the right path if that's what you're looking to do.

Code:
Sub varTest()
  ' Testing how to store and retrieve a variable saved with the doc.

  ActiveDocument.Variables.Add Name:="Value1", Value:="1"
  
  MsgBox ActiveDocument.Variables("Value1") + 3

  For Each myVar In ActiveDocument.Variables
    Debug.Print ("Name = " & myVar.Name & vbCr & "Value = " & myVar.Value)
  Next myVar

End Sub
Reply With Quote