FormFields().Result - hidden text

G

Graig

Good day all,

I have the following Word 2000 VBA code:

txtTemp = ActiveDocument.FormFields("myField").Result

However, I'm having trouble with the statement returning a
".Result" if the FormField is Font Formatted as "Hidden" text.

The following statement has no trouble setting the "myField"
value, even when it is Font Formatted as "Hidden" text.

ActiveDocument.FormFields("myField").Result = 1234.56

Is this a VBA "feature"?
Is there a work-around?

Thanks in advance,

Graig
 
J

Joost Verdaasdonk

Hi Graig,

Not a pretty method but affective:
Sub HiddenFieldResult()
Dim sField As String
Dim sFField As Word.FormField

Application.ScreenUpdating = False
Set sFField = ActiveDocument.FormFields("bm2")

With sFField
.Range.Font.Hidden = False
sField = .Result
.Range.Font.Hidden = True
End With
MsgBox sField

Set sFField = Nothing
End Sub

If you need to shut down protection depends on how you
are running this sub (macro attacht to field or not)

Groetjes,
Joost Verdaasdonk
 

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