lose formatting when exporting to Word

  • Thread starter Thread starter Meryl
  • Start date Start date
M

Meryl

I have a donations template letter that I have in Word.
From access I want to pass the amount and insert it into
the letter
using a bookmark. All goes well, but I lose the currency
formatting. For numbers 1,000 and above, no comma
appears in the word document and I can't figure out why.
When I export data from the same table into Excel, I see
both the comma and the dollar sign. Can you tell me what
is wrong with the code below? Thank you. Meryl

Private Sub Donation_Letter_Word_Click()
On Error GoTo Err_Donation_Letter_Word_Click

Dim oApp As Object

Set oApp = CreateObject("Word.Application")
oApp.Visible = True

Dim curAmount As Currency
curAmount = Forms![Donor-Registration Form-US]!
[individual donations subform]!Amount

' Open Microsoft Word using automation


oApp.Documents.Add "C:\Windows\Application
Data\Microsoft\Templates\RegDonationLetter.dot"
oApp.Visible = True

' The following code is generated from your Access form
while it is
' manipulating an instance of Word.
' So, while it looks somewhat like VBA, it's really Word
VBA.

If oApp.ActiveDocument.Bookmarks.Exists("Amount") = True
Then
oApp.ActiveDocument.Bookmarks("Amount").Range.Text =
curAmount
End If

Exit_Donation_Letter_Word_Click:
Exit Sub
 
Hello Meryl,

I have been able to get Word to recognize the Currency format by explicitly
formatting the value I want to pass to the template:

objApp.ActiveDocument.Bookmarks("Amount").Range.Text = Format(curAmount,
"Currency")


hth,
 
Back
Top