Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Guys
How can i access the Name of the variables that has been created in variable overview in macro.
I am using Following Macro Script but it is giving me name of the variables apart from i have created.
Set Vars = ActiveDocument.GetVariableDescriptions
For k = 0 to vars.Count - 1
Set v = vars.Item(k)
MsgBox(v.Name)
Next
Guys Please help .....
I haven't found a property to distinguish a user defined variable from a system variable. The only thing I can think of is starting at 25 to skip the system variables: For k = 25 to vars.Count - 1
Hi Manish,
Gysbert is right... there is no inherit property to distinguish whether it's User or Sytem variables. However, if you can follow a standard naming convention while creating the variables then you can use string/ pattern search to identify whether its User or System variable. And this is good practice when you have more than handful of variables. I always follow a standard naming convention, something like this:
Generic Variables:
v_HideShow
v_MyString
v_ConcatFieldValue
Expression Variables:
v_Exp_TotalSales
v_Exp_AvgSales
v_Exp_MonthlySales
Colour Variables:
v_Colour_Primary_01
v_Colour_Primary_02
....
....
Once you follow the standard naming convention then you easily call your variables by using below script.
Sub VariableNames
Set Vars = ActiveDocument.GetVariableDescriptions
For k = 0 to vars.Count - 1
Set v = vars.Item(k)
IF Left(v.Name, 2) = "v_" Then
MsgBox(v.Name)
Else
End if
Next
End Sub
I hope this helps!
Good luck!
Cheers,
DV