Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Aug 2001
    Location
    Washington, DC
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word Calculation Fields Format (Word 2000)

    I'm updating our travel expense form to accommodate our new international offices. I've figured out a way to format the regular text form fields with the appropriate currency symbol (selected from a dialog box). However, I can't figure out how to set the format for the calculation fields. The maddening thing is, the code I wrote should work, it just doesn't! The code is as follows (where currencytype is the appropriate symbol and chr(34) is the double-quote symbol):

    currformat = Chr(34) & currencytype & "#,##0.00;(" & currencytype & "#,##0.00)" & Chr(34)
    ActiveDocument.FormFields("taxicash").TextInput.Ed itType Type:=wdCalculationText, Format:=currformat

    If currencytype is, say, the

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Calculation Fields Format (Word 2000)

    Does the field contain any data? I noticed that it looks like there's no format, but when you enter form data, the formatting shows up.

    I also tried using a different type: wdNumberText

    Also, do you need the chr(34)'s?

    This code seems to work fine:

    currformat = currencytype & "#,##0.00;(" & currencytype & "#,##0.00)"
    With ActiveDocument.FormFields.Add(Range:=Selection.Ran ge, Type:=wdFieldFormTextInput)
    .Name = "TaxiCash"
    .TextInput.EditType Type:=wdNumberText, Format:=currformat
    .Enabled = True
    '.Result = "99.90"
    End With
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    New Lounger
    Join Date
    Aug 2001
    Location
    Washington, DC
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Calculation Fields Format (Word 2000)

    Thanks for your reply. Unfortunately, I already knew how to set the format for a TextInput form field, it's the calulation form fields I'm having trouble with. The field doesn't contain data per se, it contains a calculation. I'd rather use a calculation field than a regular field, because that way the calculation updates whenever you print (if you have fields set to update when you print, as we do) and so it's much less likely that the "answers" will be wrong when they submit the forms.

    I don't know if I need the chr(34)s or not; I just put that in so that the variable would contain the quotes, which the Format method seems to require.

  4. #4
    New Lounger
    Join Date
    Aug 2001
    Location
    Washington, DC
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Calculation Fields Format (Word 2000)

    Never mind! My original code actually does work (without the chr(34)s). Most of the calculating is done by the calculation fields, but I do some calculations in the code. However, if I do the calculating first, the formatting won't take, for some bizarre reason. If I do the formatting first, however, everything's dandy!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •