Hi all,
I try to print out a word document from within access vba so that it it
printed in the background when I set word document to visible:=False
this is the function where the error occurs:
________________________
Public Function PrintBill() As Boolean
Dim printedOK As Boolean
---> getting an automation error because of wrong syntax
Set wdApp = GetObject(Word.Application)
Set DC = GetObject(Word.ActiveDocument)
--->
wdApp.ActiveWindow.PrintOut DC, Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=2, Pages:="",
PageType:=wdPrintAllPages, _
Collate:=False
wdApp.ActiveDocument.Close
Set DC = Nothing
Set wdApp = Nothing
PrintBill = True
End Function
__________________________
I set the word application visible so I have to go to word and press the
print button manually.
Any help most welcome as I don't have a clou as to what the syntax might be
Thanks,
Gina
Jezebel - 03 Mar 2005 22:14 GMT
When you use GetObject, you need to put quotes around the class -- it's a
literal.
Set wdApp = GetObject("Word.Application")
Set DC = wdApp.ActiveDocument
If Word is invisible, there is no ActiveWindow. But you don't need it. Just
print the document --
DC.PrintOut
> Hi all,
> I try to print out a word document from within access vba so that it it
[quoted text clipped - 34 lines]
> Thanks,
> Gina
Gina - 06 Mar 2005 11:36 GMT
Hi Jezebel.
Tried it before and tried it right now like
Public Sub PrintIt()
Set DC = GetObject(Word.ActiveDocument)
* DC.PrintOut(Copies:=2)
End Sub
* I got an error and now I changed it to
DC.PrintOut Copies:=2
and it works fine
Thanks a lot ....
Gina
> When you use GetObject, you need to put quotes around the class -- it's a
> literal.
[quoted text clipped - 45 lines]
> > Thanks,
> > Gina