PDA

Click to See Complete Forum and Search --> : how do i print all files in a folder?


j4th
Aug 13th, 2001, 01:17 PM
hi,
i'm new to vb programming, and i was wondering if anyone could help me out. just like the subject says, i want to print all the files of a certain filetype in a folder to a certain printer. my pseudocode thus far looks like this:

'start pseudocode
vars&stuff
input dir
output doc dir
error doc dir
output pdf dir
default printer
desired printer (acrobat distiller)
array for filenames

find default printer
change default to distiller
create array of docs in input dir
open word
for
open doc
print to printer
?
if no error log move to done folder
else move to error folder
?
close doc
end
restore default printer
'end pseudocode

like i said, i'm new at this, so i'm still getting used to vb syntax. anyway, my main problems-- how to change the printer, how to loop (something like "For Each file in folder"?). any help would be appreciated.

-j-

jim mcnamara
Aug 13th, 2001, 02:03 PM
This is how to find files of all one type in a folder:

http://www.vbforums.com./showthread.php?s=&threadid=96116

This enumerates (shows) all printers

Dim oPtr as Object
For each oPtr in Printers
msgbox oPtr.DeviceName, vbokonly
next


Assuming it's a text file this prints the file

open filename for input as #1
Do while not eof(1)
line input #1, a$
Printer.Print a$
Loop
Printer.EndDoc



You use the common dialog control with .showprinter to select which printer you want to use.

Printing pdf's is a whole 'nother problem. Do a search on this forum (not just api) for pdf. Basically you have to automate Acrobat to print a pdf file.

j4th
Aug 13th, 2001, 02:58 PM
thx jim;
actually, i'm not trying to print pdfs. i'm just sending my print jobs to acrobat distiller so it outputs pdfs-- i'm probably going to use shellexecute to have my files print.


thx again
-j-