View Single Post
  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Text form field loses formatting in Word 2010


That is an issue that I came across last week. A way around the problem is
to run the following macro on exit from any formfield to which you want to
apply the formatting:

Sub formatfldresult()
Dim ffname As String
ffname = Selection.Bookmarks(Selection.Bookmarks.Count).Nam e
With ActiveDocument.FormFields(ffname)
.Result = Format(.Result, "$#,###.00")
End With
End Sub


--
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, originally posted via msnews.microsoft.com

"Michelle H." Michelle wrote in message
...
I am trying to create a very simple form in Word 2010 (RTM, on Win7) which
has three fields: Qty, Unit Price, Ext. Price. Am using the legacy Text
Form
field for each. The details on how I set up properties is below.
I restrict editing and then save it (as a DOTX, DOCX or even DOC-tried
all),
and then open it to type values in my fields. Here's the problem: the
fields
do not format the data as instructed. For example, I type in a unit price
of
$1.50 and it saves the value of "1". That's it, just the number 1, and
does
not format it as instructed (as currency). It displays the qty correctly,
but it strips out the currency formatting for Ext. Price as well. All
calculations are working (based on the values it saves in the form field,
not
the values I've typed in), but the formatting is in error, and that makes
the
calculation results wrong.

When I go back and view properties for each field, the number format is
blank - as if I never selected/changed it. If I select again, restrict,
save, and try again, still no formatting.
What might be causing this? I've tried in an old document and a brand new
one and the same thing happens. Information from this point forward is
supplemental about how I set properties for each field.

After I insert each field, I open the Properties and make appropriate
changes:
Qty field: Number type, unlimited length, number format #,##0, calculate
on
exit checked.
Unit Price field: Number type, unlimited length, number format
$#,##0.00;($#,##0.00), calculate on exit checked.
Ext price field: Calculation, unlimited length, number format
$#,##0.00;($#,##0.00), calculate on exit NOT checked.
Editing restrictions are set to allow only Filling in forms.

Thanks for any insights you might have.