Imraan
Imraan

Reputation: 69

Formatting numbers in Word table to display as currency using VBA

I have VBA code that I run from MS Access. This code creates tables (of different sizes depending on the size of a query) in a Word document, and thereafter fills that Word document, with values from a query's columns using the Range.Text property. One of these columns is a currency value and another a percentage value. These values display correctly in Access itself.

Unfortunately values are outputted as eg. 987.6 and 1234.5, instead of 987.60 and 1234.50. As small as this is, it is a requirement and was hoping to find a solution and I am entirely unsure how to do this or if its even possible. Discounts are displayed as 0.18 or 0.30 instead of 18 and 30

I can show my code for the export of the data if required however didn't see how it affected this part that I require.

Upvotes: 1

Views: 1166

Answers (1)

Vityata
Vityata

Reputation: 43585

That is the answer:

Format(123123, "Currency")

The currency would be from your local settings.

Edit: See the screenshot - open the immediate window, there you may write ?Format(123123, "Currency") and you will see the result. Screenshot attached.

enter image description here

Upvotes: 1

Related Questions