bradmaunsell
Programmer
I fumbling with a WORD subroutine and have a printing problem using the PRINTOUT method.
Windows 2000, Access 97 Word 2000
I push a button on an Access 97 form to run a subroutine that opens a Word Template and then is suppose to print the document and close Word and return to Access 97.
The template is opened and displayed but stops with an error dialog box message saying:
"Word is currently printing. Quitting Word will cancel all pending print jobs. Do you want to quit Word? (Yes or No)
If I answer NO the system prints as requested and Word stays open.
If I answer YES, Word closes and I am retured to my Access 97 form (without printing).
Here is my code:
Sub CreateFPE101()
CreateNewWordInstance
strTemplate = "FPE101_GeneralChangeEndorsement.dot"
CreateWordDocument (strTemplate)
oWord.Application.ActiveDocument.PrintOut
oWord.Application.Quit
Set oWord = Nothing
End Sub
Public Sub CreateNewWordInstance()
' Requires Microsoft Word 9.0 Object Library
On Error Resume Next
Set oWord = GetObject(, "Word.Application"
'Try to get an open word object
If Err.Number = 429 Or Err.Number = 0 Then 'No word objects currently open so create one
Set oWord = CreateObject("Word.Application"
ElseIf Err.Number <> 0 Then
MsgBox "Ooops!! Found an open Word instance!! Error: " & Err.Description
Exit Sub
End If
oWord.Visible = True
oWord.Activate 'Bring word application to top
End Sub
Public Sub CreateWordDocument(strTemplateName)
pathAddNewWordDoc = pathGetWordTemplate & "\" & strTemplateName
oWord.Documents.Add pathAddNewWordDoc, NewTemplate:=False, DocumentType:=0 'Open new Word document using .dot template
End Sub
I have temporarily removed the population routines to simplify the trouble shooting process.
Thanks for any help.
Brad
South Burlington, Vermont
Windows 2000, Access 97 Word 2000
I push a button on an Access 97 form to run a subroutine that opens a Word Template and then is suppose to print the document and close Word and return to Access 97.
The template is opened and displayed but stops with an error dialog box message saying:
"Word is currently printing. Quitting Word will cancel all pending print jobs. Do you want to quit Word? (Yes or No)
If I answer NO the system prints as requested and Word stays open.
If I answer YES, Word closes and I am retured to my Access 97 form (without printing).
Here is my code:
Sub CreateFPE101()
CreateNewWordInstance
strTemplate = "FPE101_GeneralChangeEndorsement.dot"
CreateWordDocument (strTemplate)
oWord.Application.ActiveDocument.PrintOut
oWord.Application.Quit
Set oWord = Nothing
End Sub
Public Sub CreateNewWordInstance()
' Requires Microsoft Word 9.0 Object Library
On Error Resume Next
Set oWord = GetObject(, "Word.Application"
If Err.Number = 429 Or Err.Number = 0 Then 'No word objects currently open so create one
Set oWord = CreateObject("Word.Application"
ElseIf Err.Number <> 0 Then
MsgBox "Ooops!! Found an open Word instance!! Error: " & Err.Description
Exit Sub
End If
oWord.Visible = True
oWord.Activate 'Bring word application to top
End Sub
Public Sub CreateWordDocument(strTemplateName)
pathAddNewWordDoc = pathGetWordTemplate & "\" & strTemplateName
oWord.Documents.Add pathAddNewWordDoc, NewTemplate:=False, DocumentType:=0 'Open new Word document using .dot template
End Sub
I have temporarily removed the population routines to simplify the trouble shooting process.
Thanks for any help.
Brad
South Burlington, Vermont