I have a Word Template which has bookmarks to data from an Access table. Everything works fine except I cannot figure out why the currency format is not retained when the document prints out. I have search the KB articles as this seems to be some MS glitch but have not been able to find a satisfactory answer. Below is the code attached to the merge button on my Access form.
Private Sub MergeButton_Click()
On Error GoTo MergeButton_Err
Dim objWord As Word.Application
' Start Microsoft Word
Set objWord = CreateObject("Word.Application"
With objWord
.Visible = True
' Open the document.
.Documents.Open ("c:\Operations\ITAR.dot"
' Move to each bookmark and insert text from the form
.ActiveDocument.Bookmarks("ProName".Select
.Selection.Text = (CStr(Forms!frmITAR!ProjectName))
.ActiveDocument.Bookmarks("Amount".Select
.Selection.Text = (CStr(Forms!frmITAR!Amount))
End With
' Print the document in the foreground so Microsoft Word
' will not close until the document finishes printing.
objWord.ActiveDocument.PrintOut Background:=False
' Close the document without saving changes.
objWord.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
' Quit Microsoft Word and release the object variable.
objWord.Quit
Set objWord = Nothing
Exit Sub
MergeButton_Err:
' If a field on the form is empty
' remove the bookmark text and continue.
If Err.Number = 94 Then
objWord.Selection.Text = ""
Resume Next
Else
MsgBox Err.Number & vbCr & Err.Description
End If
Exit Sub
End Sub
I need to retain the currency format. Any suggestions? Thanks much.
Private Sub MergeButton_Click()
On Error GoTo MergeButton_Err
Dim objWord As Word.Application
' Start Microsoft Word
Set objWord = CreateObject("Word.Application"
With objWord
.Visible = True
' Open the document.
.Documents.Open ("c:\Operations\ITAR.dot"
' Move to each bookmark and insert text from the form
.ActiveDocument.Bookmarks("ProName".Select
.Selection.Text = (CStr(Forms!frmITAR!ProjectName))
.ActiveDocument.Bookmarks("Amount".Select
.Selection.Text = (CStr(Forms!frmITAR!Amount))
End With
' Print the document in the foreground so Microsoft Word
' will not close until the document finishes printing.
objWord.ActiveDocument.PrintOut Background:=False
' Close the document without saving changes.
objWord.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
' Quit Microsoft Word and release the object variable.
objWord.Quit
Set objWord = Nothing
Exit Sub
MergeButton_Err:
' If a field on the form is empty
' remove the bookmark text and continue.
If Err.Number = 94 Then
objWord.Selection.Text = ""
Resume Next
Else
MsgBox Err.Number & vbCr & Err.Description
End If
Exit Sub
End Sub
I need to retain the currency format. Any suggestions? Thanks much.