J
James T.
Access 2000
I have a small database that I have to issue a work order
for each record each week. I would like to output it to a
document that is a template for the work order. I can do
this for one record, but I would like to do it for all
records at one time with a separate work order for each
record. I have tried doing this in a report, but couldn't
get it to work. I am more comfortable doing it in a
document with bookmarks. Here is a sample of my code that
will print one record:
Private Sub Command10_Click()
' start Microsoft Word.
Set wordApp = CreateObject("Word.Application")
With wordApp
' Make the application visible.
.Visible = True
' Open the document.
.Documents.Open
("C:\DataLetters\NoticeToProceed.doc")
' Move to each bookmark and insert text from the
form.
.ActiveDocument.Bookmarks("To").Select
.Selection.Text = (CStr(Forms!Proceed!To))
.etc ....
End With
'''objWord.ActiveDocument.PrintPreview
wordApp.ActiveDocument.PrintOut Background:=False
wordApp.ActiveDocument.Close wdDoNotSaveChanges
wordApp.Quit wdDoNotSaveChanges
Set wordApp = Nothing
Exit Sub
MergeButton_Err:
' If a field on the form is empty
' remove the bookmark text and continue.
If Err.Number = 94 Then
wordApp.Selection.Text = ""
Resume Next
End If
End Sub
Is there anyway to do all records?
Any help greatly appreciated.
Thanks,
James
I have a small database that I have to issue a work order
for each record each week. I would like to output it to a
document that is a template for the work order. I can do
this for one record, but I would like to do it for all
records at one time with a separate work order for each
record. I have tried doing this in a report, but couldn't
get it to work. I am more comfortable doing it in a
document with bookmarks. Here is a sample of my code that
will print one record:
Private Sub Command10_Click()
' start Microsoft Word.
Set wordApp = CreateObject("Word.Application")
With wordApp
' Make the application visible.
.Visible = True
' Open the document.
.Documents.Open
("C:\DataLetters\NoticeToProceed.doc")
' Move to each bookmark and insert text from the
form.
.ActiveDocument.Bookmarks("To").Select
.Selection.Text = (CStr(Forms!Proceed!To))
.etc ....
End With
'''objWord.ActiveDocument.PrintPreview
wordApp.ActiveDocument.PrintOut Background:=False
wordApp.ActiveDocument.Close wdDoNotSaveChanges
wordApp.Quit wdDoNotSaveChanges
Set wordApp = Nothing
Exit Sub
MergeButton_Err:
' If a field on the form is empty
' remove the bookmark text and continue.
If Err.Number = 94 Then
wordApp.Selection.Text = ""
Resume Next
End If
End Sub
Is there anyway to do all records?
Any help greatly appreciated.
Thanks,
James