C
Chris Mahoney
Hi
I'm trying to print a Word document from my VB 2005 app, but I'm having
trouble.
Imports Microsoft.Office.Interop
Private oWord As Word.Application
Private WordTemplate As Object = "N:\Checklist.dot"
Public Sub PrintDocument()
Dim oDoc As Word.Document
oWord = New Word.Application
oDoc = oWord.Documents.Add(WordTemplate)
oDoc.PrintOut()
oDoc.Close(Word.WdSaveOptions.wdDoNotSaveChanges)
oWord.Quit()
End Sub
When I run the code, the document gets printed, but then I get an error
on the .Close line:
System.Runtime.InteropServices.COMException
Exception from HRESULT: 0x800A14EC
at Microsoft.Office.Interop.Word.DocumentClass.Close(Object&
SaveChanges, Object& OriginalFormat, Object& RouteDocument)
Can anyone tell me what I am doing wrong?
Thanks
Chris
I'm trying to print a Word document from my VB 2005 app, but I'm having
trouble.
Imports Microsoft.Office.Interop
Private oWord As Word.Application
Private WordTemplate As Object = "N:\Checklist.dot"
Public Sub PrintDocument()
Dim oDoc As Word.Document
oWord = New Word.Application
oDoc = oWord.Documents.Add(WordTemplate)
oDoc.PrintOut()
oDoc.Close(Word.WdSaveOptions.wdDoNotSaveChanges)
oWord.Quit()
End Sub
When I run the code, the document gets printed, but then I get an error
on the .Close line:
System.Runtime.InteropServices.COMException
Exception from HRESULT: 0x800A14EC
at Microsoft.Office.Interop.Word.DocumentClass.Close(Object&
SaveChanges, Object& OriginalFormat, Object& RouteDocument)
Can anyone tell me what I am doing wrong?
Thanks
Chris