Is there a way to delete a Private field?

M

MMWeiner

I was sent a form that contains private fields throughout the document, they
do not show up when completing the document but as soon as you print or print
preview I get an error message "Error! Bookmark not defined". Is there
anyway to prevent this from happening?
 
M

MMWeiner

It is a form I use over and over and no matter how many times I try it
happens everytime I click to print. Is there anyway to permanently delete it
from the template itself. (it also seems that the people that sent me the
form do not know where this field came from).
 
S

Suzanne S. Barnhill

Are you saying that, when you press Alt+F9 to look at the form template,
there is no field in the position where you are getting the error message?

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 
G

Graham Mayor

Private fields will almost certainly be marked as hidden, so you would only
see them with hidden text displayed. The following macro should remove them
from the document or template hidden or not.

Sub RemovePrivate()
Dim oSection As Section
Dim oStory As Range
Dim oHeader As HeaderFooter
Dim oFooter As HeaderFooter
With ActiveDocument
For Each oStory In .StoryRanges
For Each oField In oStory.Fields
If InStr(1, oField.Code, "PRIVATE") Then
oField.Delete
End If
Next oField
Next oStory
For Each oSection In .Sections
For Each oHeader In oSection.Headers
If oHeader.Exists Then
For Each oField In oHeader.Range.Fields
If InStr(1, oField.Code, "PRIVATE") Then
oField.Delete
End If
Next oField
End If
Next oHeader
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
If InStr(1, oField.Code, "PRIVATE") Then
oField.Delete
End If
Next oField
End If
Next oFooter
Next oSection
End With
End Sub

http://www.gmayor.com/installing_macro.htm


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top