Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Jack F Jack F is offline
external usenet poster
 
Posts: 1
Default Do not print blank form fields

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?
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Do not print blank form fields

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

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




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?



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Do not print blank form fields

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?



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to I print only non-blank fields in Mail Merge? Kathleen Mailmerge 11 May 9th 23 08:52 PM
Blank return for drop-down form fields Peter B. Microsoft Word Help 4 January 26th 07 06:01 PM
Blank Merge Fields Still Print when told not to. JohnH Mailmerge 8 December 16th 06 04:47 PM
How to use mail merge to send out a form with blank text fields? Gwendolyn Mailmerge 1 November 17th 05 06:16 AM
In mail merge I don't want to print blank fields Richard Mailmerge 7 July 11th 05 03:45 PM


All times are GMT +1. The time now is 11:48 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"