beth_83
04-23-2006, 06:31 PM
I am trying to show / hide text according to the purpose of a letter. It is a mail merged letter that will then show additional text (including merge fields) based on a macro button that the user clicks.
I have tried this code but get an error message: Object variable or With block variable not set.
Dim lPara As Long
With ActiveDocument
For lPara = .Paragraphs.Count To 1 Step -1
With .Paragraphs(lPara)
If .Range.Style = "EmailStyle" Then
.Range.Font.Hidden = True
End If
End With
Next
End With
Any help with this would be greatly appreciated. Other code that I have tried is:
Sub ShowFaxStyle()
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("FaxStyle")
MsgBox Selection.Find.Style
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Hidden = False
End Sub
However the above code seems to do nothing!
Cheers
Beth
I have tried this code but get an error message: Object variable or With block variable not set.
Dim lPara As Long
With ActiveDocument
For lPara = .Paragraphs.Count To 1 Step -1
With .Paragraphs(lPara)
If .Range.Style = "EmailStyle" Then
.Range.Font.Hidden = True
End If
End With
Next
End With
Any help with this would be greatly appreciated. Other code that I have tried is:
Sub ShowFaxStyle()
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("FaxStyle")
MsgBox Selection.Find.Style
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Hidden = False
End Sub
However the above code seems to do nothing!
Cheers
Beth