Cell content must appear as $#.##

M

MIrving

In Word 97, is it possible to set up cells in a table so that the value in a
cell automatically appears as $#.##, irrespective of how a user enters the
amount? Thanks.
 
D

Doug Robbins - Word MVP

It is not possible with a Word table. You can however insert an Excel
Spreadsheet, which, except when the user is actually working in the
spreadsheet, will be indistinguisable from a Word table. You can then make
use of the cell formatting abilities of Excel.

--
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
 
M

MIrving

Thank you for answering it. As an alternative, is it possible to either:

1. In a VB userform, force a textbox entry (ie. whatever the user inputs)
to always be displayed as $#.##, irrespective of how the number is entered
into the textbox; or

2. On clicking of the commandbutton in a userform, force the insertion of
the text from each textbox into the Word document bookmark to always be
displayed as $#.##.

Thank you for any suggestions.
 
D

Doug Robbins - Word MVP

Yes, that is certainly possible by the use of the Format() function

On exit from a textbox (TxtBoxCurrency)

txtBoxCurrency.Text = Format(txtBoxCurrency.Text, "$#,###,00")

Once you have the data formatted that way in the text box, as it is actually
a String, that is how it will be inserted into the document.

--
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
 
M

MIrving

Thank you, that's great. A really basic question I'm sure, but where do I
put txtBoxCurrency.Text = Format(txtBoxCurrency.Text, "$#,###,00")? Thanks
again.
 
D

Doug Robbins - Word MVP

In the Exit event of the textbox.

--
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
 
M

MIrving

Thank you. When I run it, I get an error 424 "object required":

Private Sub Price_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtBoxCurrency.Text = Format(txtBoxCurrency.Text, "$#,###,00")
End Sub

Where have a gone wrong? Thank you for your help.
 
L

Lene Fredborg

If the name of your TextBox is "Price", you must refer to that name in your
code. Instead of:

txtBoxCurrency.Text = Format(txtBoxCurrency.Text, "$#,###,00")

use

Price.Text = Format(Price.Text, "$#,###,00")

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 

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