Problem is that with the hidden text displayed, I can edit and change that but everything I do is not kept as it disappears the next time I toggle.
Seems the only way to change the advanced text is in the Alt-F9 mode where I display the field...
Now that is disappointing and cumbersome... Back to the paragraph style?
My document has this test field:
Code: Select all
{ IF {DOCVARIABLE "EJH" } ="v" <hidden text and formatting here>" ""}
Code: Select all
Private Sub EJH_Hide_Click()
'One time use only to create variable EJH if it does not exist
'ActiveDocument.Variables("EJH").Delete
Dim oVars As Variables, D
Set oVars = ActiveDocument.Variables
On Error Resume Next
D = oVars("EJH").Value
If Err.Number = 5825 Then ActiveDocument.Variables.Add Name:="EJH", Value:="v"
'Toggle (v=visible, h=hidden)
If D = "v" Then
D = "h"
EJH_Hide.Caption = "Normal"
Else
D = "v"
EJH_Hide.Caption = "Extended"
End If
'Apply
With ActiveDocument
.Variables("EJH") = D
.Fields.Update
End With
End Sub