ShowFieldCodes

U

Ulf Nilsson

When I use ActiveWindow.View.ShowFieldCodes = False the field codes still
show in fields that are not field in.

I use { DOCPROPERTY AV_txtA \* MERGEFORMAT }, and in all the fields that are
filled in the text shows. But the fields that are not filled in, the field
codes are shown.

Why?

// Ulf
 
D

DaveLett

Hi Ulf,
It could be that you have manually toggled the field code in the Word
document. I prefer to cycle through the fields collection to ensure that each
field shows the codes.

Dim oFld As Field
For Each oFld In ActiveDocument.Fields
oFld.ShowCodes = True
Next oFld

If you have field codes in other ranges (e.g., header/footer), then you will
have to cycle through all of those, too.

HTH,
Dave
 
U

Ulf Nilsson

Thanks Dave,
I had thought of that option, but was hoping that there was a simplier
solution.

I came up with another solution. When I insert the field code in the
document, I do like this:

With Selection
.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"DOCPROPERTY " & sProp & " ", PreserveFormatting:=True
.MoveLeft unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Fields(1).ShowCodes = False
.MoveRight unit:=wdCharacter, Count:=1
End With

As far as I can see, this works because it toogles the ShowCodes = False
everytime it inserts the code.

// Ulf
 

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