printing files from a directory

S

Suzette

I checked help on Word and found some code that will print a bunch of files
in a directory but I'm having problems using Automation to do it from
another program.

Here's the help. This code works splendidly in Word:

adoc = Dir("*.DOC")
While adoc <> ""
Application.PrintOut FileName:=adoc
adoc = Dir()
WendHere's my code. This is embedded in another program. I have a
reference set to Word. When it gets to the printout line I get an error.
"This method or property is not available because a document window is not
active."


Dim adoc As String
Dim wdapp As Word.Application
Set wdapp = New Word.Application

adoc = Dir("*.DOC")
While adoc <> ""
wdapp.Application.PrintOut FileName:=adoc
adoc = Dir()
Wend
wdapp.Quit
Set wdapp = Nothing


Any ideas, suggestions?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top