Oops!
( Forgot to include the command to print the document with the
fields hidden
Dim i As Integer
Dim bProtected As Boolean
Dim bHidden As Boolean
Dim sPassword As String
sPassword = ""
bHidden = ActiveWindow.View.ShowHiddenText
ActiveWindow.View.ShowHiddenText = False
With ActiveDocument
If .ProtectionType wdNoProtection Then
bProtected = True
.Unprotect Password:=sPassword
End If
For i = .FormFields.Count To 1 Step -1
If Len(.FormFields(i).Result) = 0 Then
'Hide the field
.FormFields(i).Range.Font.Hidden = True
'or Hide the paragraph containing the field
'.FormFields(i).Range.Paragraphs(1) _
.Range.Font.Hidden = True
End If
Next i
If bProtected = True Then
.Protect _
Type:=wdAllowOnlyFormFields, _
NoReset:=True, _
Password:=sPassword
End If
.PrintOut
End With
ActiveWindow.View.ShowHiddenText = bHidden
--
Graham Mayor - Word MVP
My web site
www.gmayor.com
Word MVP web site
http://word.mvps.org
Graham Mayor wrote:
You need a macro
Dim i As Integer
Dim bProtected As Boolean
Dim bHidden As Boolean
Dim sPassword As String
sPassword = ""
bHidden = ActiveWindow.View.ShowHiddenText
ActiveWindow.View.ShowHiddenText = False
If ActiveDocument.ProtectionType wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=sPassword
End If
With ActiveDocument
For i = .FormFields.Count To 1 Step -1
If Len(.FormFields(i).Result) = 0 Then
'Hide the field
.FormFields(i).Range.Font.Hidden = True
'or Hide the paragraph containing the field
'.FormFields(i).Range.Paragraphs(1) _
.Range.Font.Hidden = True
End If
Next i
End With
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, _
Password:=sPassword
End If
ActiveWindow.View.ShowHiddenText = bHidden
http://www.gmayor.com/installing_macro.htm
Jack F wrote:
I have made Word documents for test reports. In conclusion there are
free text and drop down form fields. How do I remove spacing on the
printed verison from form fields that are left blank?