Hi all,
I am trying to use fields and variables to toggle content.
I have a DocVariable field (named FL1), and a variable (named RFL1) in the document.
I store the value of the field FL1 in the variable RFL1.
Here is my code:
Sub HideWithVariable()
ActiveDocument.Variables("RFL1").Value = ActiveDocument.Variables("FL1").Value
ActiveDocument.Variables("FL1").Value = ""
ActiveDocument.Range.Fields.Update
End Sub
Sub ShowWithVariable()
ActiveDocument.Variables("FL1").Value = ActiveDocument.Variables("RFL1").Value
ActiveDocument.Range.Fields.Update
End Sub
This work, but the problem is that the formatting is lost.
Is there a way to retain the formatting in the variable?
Or else, is there a field type better suited for this?
TIA,
Sheila
PS: I can select the field, and use font.hidden = true/false
But that method works very slowly when I have hundreds of fields in a document. I am trying to use Fields.Update
I am trying to use fields and variables to toggle content.
I have a DocVariable field (named FL1), and a variable (named RFL1) in the document.
I store the value of the field FL1 in the variable RFL1.
Here is my code:
Sub HideWithVariable()
ActiveDocument.Variables("RFL1").Value = ActiveDocument.Variables("FL1").Value
ActiveDocument.Variables("FL1").Value = ""
ActiveDocument.Range.Fields.Update
End Sub
Sub ShowWithVariable()
ActiveDocument.Variables("FL1").Value = ActiveDocument.Variables("RFL1").Value
ActiveDocument.Range.Fields.Update
End Sub
This work, but the problem is that the formatting is lost.
Is there a way to retain the formatting in the variable?
Or else, is there a field type better suited for this?
TIA,
Sheila
PS: I can select the field, and use font.hidden = true/false
But that method works very slowly when I have hundreds of fields in a document. I am trying to use Fields.Update