Print list from external Script.scr file

C

CLR

Hi All......

I have an Excel Add-in that will output to a separate Script.scr file, a
list of path and filenames that I wish to print. I can get AutoCAD to read
that list and open and print all it's .dwg files.........I am trying to get
Word to read that Script.scr file and open and print the .doc files therein?
I can control it so there will only be .doc files in the Script.scr file.
Anybody got any ideas?

Any help would be appreciated......

Vaya con Dios,
Chuck, CABGx3
 
J

Jay Freedman

Hi, Chuck,

I think this will do what you need. It assumes that each file name in
script.scr ends with a carriage return.

Sub PrintFromList()
Dim strListFile As String
Dim strFileToPrint As String
Dim oDoc As Document

On Error GoTo NoScript

strListFile = "c:\temp\script.scr"
Open strListFile For Input As #1

On Error GoTo ErrHdl
Do While Not EOF(1)
Line Input #1, strFileToPrint
If Len(strFileToPrint) Then
Set oDoc = Documents.Open(strFileToPrint)
With oDoc
.PrintOut Background:=False
.Close savechanges:=wdDoNotSaveChanges
End With
ResumeHere:
End If
Loop
Close #1

Exit Sub

NoScript:
MsgBox prompt:="Could not open " & strListFile, Title:="Error"
Exit Sub

ErrHdl:
MsgBox prompt:=Err.Description, Title:="Error"
Err.Clear
On Error GoTo ErrHdl
Resume ResumeHere
End Sub
 
C

CLR

Thanks muchly Jay.......that seems to be exactly what I'm looking for, but
my tired ole eyes can't comprehend it tonight.....I'm ready to crash, but
will for sure give it a go tomorrow......I really appreciate your
help.......you guys are lifesavers.....

Vaya con Dios,
Chuck, CABGx3
 
C

CLR

Thats it Jay........your code worked perfectly......it's exactly what I was
looking for. You are a Gentleman and a Scholar, kind Sir...........I Thank
you.

Vaya con Dios,
Chuck, CABGx3
 

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