hiding index field code (work 2k)

K

ken

I've been unable to hide the index field codes in my document. I've tried
the alt-f9 and cntl-f9 tricks as per the help command.

Also, how I stop word from changing my document every time I open it -
sections are changing from left align to justify, from 12 point Time Roman
to 9 point Courier New.

TIA
 
D

Doug Robbins - Word MVP

You can be the beneficiary of the wanker who never paid up after posting a
request for this in one of these newsgroups offering a case of beer as a
reward:

' Macro created 21 March 1999 by Doug Robbins to hide XE fields
'
Dim axe As Field
For Each axe In ActiveDocument.Fields
axe.Select
If Mid(Selection.Text, 3, 2) = "XE" Then
RangeStart =
Selection.Information(wdHorizontalPositionRelativeToPage)
Selection.Collapse Direction:=wdCollapseEnd
RangeEnd = Selection.Information(wdHorizontalPositionRelativeToPage)
RangeLength = RangeEnd - RangeStart
axe.Select
Selection.Font.ColorIndex = wdWhite
Selection.Collapse Direction:=wdCollapseEnd
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
Text:= _
"ADVANCE \l " & RangeLength & """, PreserveFormatting:=False"
End If
Next axe

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
H

Howard Kaikow

Does the following do the deed?

Dim fldCurrent As Word.Field
For Each fldCurrent In ActiveDocument.Fields
With fldCurrent
If .Type = wdFieldIndex Then
.ShowCodes = False
End If
End With
Next fldCurrent
Set fldCurrent = Nothing
 
K

ken

Doug,

Thanks for the reply. I think I know why the other person didn't pay up -
the macro replaced all my XE with "Error!" in the document. I had to fix a
couple of e-mail induced errors in the macro. I think I understand what
this macro does - replace the black text of the XE field with white text
which hides the field. But what's strange in my case; on my desktop, I can
hide/view the XE fields by clicking the show/hide paragraph icon and the
index entries show/hide as well. But on my laptop, this action has no
effect, the index entries are visible all the time. When I print the
document - it print without the index entries as one would expect. I've
looked in the option tab settings to make sure I have what I would expect to
be the correct options set to control this behavior.
 
D

Doug Robbins - Word MVP

Not sure why you are getting the errors. The guy who requested it
originally reported that it did what he was after; he just never delivered.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

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