I have different formats for different data. If I format the data first I
have to then know which piece of data I have, whereas now I am blissfully
ignorant of anything more than matching the data source (Excel) name to the
data target (Word bookmarked form field). The idea of formatting the data in
Excel isn't as appetizing either, as I don't always want the data in the
same format as when it is in the document.
Thanks,
Eric
How are you populating the formfields? Show use the code.
Sometimes a state of bliss will not get you what you want.

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
>I have different formats for different data. If I format the data first I
>have to then know which piece of data I have, whereas now I am blissfully
[quoted text clipped - 29 lines]
>>> frmFlds(1).Select
>>> End Sub
Eric - 04 Jan 2008 05:55 GMT
Public Sub PopulateContractFormFields()
On Error GoTo PopulateContractFormFields_Error
Dim frmFields As Word.FormFields
Set frmFields = MContractDoc.ContractDocument.FormFields
Dim bkMarks As Word.Bookmarks
Set bkMarks = MContractDoc.ContractDocument.Bookmarks
Dim ff As Word.FormField
Dim thisNamedRange As String
Dim thisValue As Variant
For Each ff In frmFields
' every bookmark name shoulld have a corresponding excel name as
well
' use bookmarks on errors from setting form field result with very
long text
thisNamedRange = ff.Name
If thisNamedRange = "" Then
thisValue = Empty
Else
thisValue = ProjectData.Range(thisNamedRange)
If IsEmpty(thisValue) Then
thisValue = ""
Else
On Error Resume Next
ff.result = thisValue
bkMarks(thisNamedRange).Range.Fields(1).result.Text =
thisValue
On Error GoTo 0
End If
End If
Next ff
On Error GoTo 0
Set frmFields = Nothing
Set bkMarks = Nothing
Exit Sub
PopulateContractFormFields_Error:
Stop
Resume
End Sub
> How are you populating the formfields? Show use the code.
>
[quoted text clipped - 34 lines]
>>>> frmFlds(1).Select
>>>> End Sub
Eric - 04 Jan 2008 05:59 GMT
Doug
Philisophy aside, isn't there some way to trigger formfield formatting via
vba?
Thanks,
Eric
> How are you populating the formfields? Show use the code.
>
[quoted text clipped - 34 lines]
>>>> frmFlds(1).Select
>>>> End Sub
Doug Robbins - Word MVP - 04 Jan 2008 09:14 GMT
If I use the following code to populate a formfield with the bookmark name
of Text2 that is formatted as currency, the result is $100.00
With ActiveDocument
.FormFields("Text2").Result = 100
End With
I am not sure why you are doing both
ff.result = thisValue
and
bkMarks(thisNamedRange).Range.Fields(1).result.Text = thisValue

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Doug
>
[quoted text clipped - 42 lines]
>>>>> frmFlds(1).Select
>>>>> End Sub
Eric - 05 Jan 2008 02:18 GMT
Thank you!! This is what I was trying to accomplish, and now can do:
If Len(thisValue) < 255 Then
' let Word doc field set format
ff.result = thisValue
Else
' avoid error (design flaw) that field.result gives on a string that's
too long
bkMarks(thisNamedRange).Range.Fields(1).result.Text = thisValue
End If
- Eric
> If I use the following code to populate a formfield with the bookmark name
> of Text2 that is formatted as currency, the result is $100.00
[quoted text clipped - 57 lines]
>>>>>> frmFlds(1).Select
>>>>>> End Sub