Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2005

Tip: Looking for answers? Try searching our database.

printing a word doc invisible - but how??

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gina - 03 Mar 2005 12:49 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.