Users want to click on a control and immediately ship a Publisher -- or
PDF -- document to the printer.
I found an old conversation with this code for Word:
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Set wdApp = New Word.Application
Set wdDoc =
wdApp.Documents.Open("\\server\Data\Inventory\Test .doc")
wdDoc.PrintOut Background:=
wdDoc.Close SaveChanges:=wdDoNotSaveChanges
wdApp.Quit
Set wdDoc = Nothing
Set wdApp = Nothing
It worked in my Access app after I set up References to include the
Microsoft Word Object Library.
"Aha!" I thought. "Just a few tweaks and I can get the same results
for a Publisher document."
So I added Microsoft Publisher Object Library to References and tried
the following code, which produces a compile error on the
pbApp.Documents.Open statement.
Dim pbApp As Publisher.Application
Dim pbDoc As Publisher.Document
Set pbApp = New Publisher.Application
Set pbDoc =
pbApp.Documents.Open("\\server\Data\Inventory\test pub1.pub")
pbDoc.PrintOut Background:=False
pbDoc.Close SaveChanges:=wdDoNotSaveChanges
pbApp.Quit
Set pbDoc = Nothing
Set pbApp = Nothing
Any insights into how I need to adjust this, or what I need to do
instead? Bonus points for code that works on PDF files!
PEmigh