Printing files from a folder

L

Linc

Does any one here know how to print files from a folder in VBA?

I have a button on a form (in Access) that when clicked it goes out and
finds all the
files in a particular folder that pertain to that form's id. That's no
problem. But...

Once it's found all the files, I want to print each file. I can write the
loop, but I can't find the right command word to make them print. Help!

Dim i As Integer
For i = 1 To .FoundFiles.count
'Print each file
'Print .FoundFiles(i) <---- What is this line supposed to be?????
Next i
 
J

Jonathan West

Linc said:
Does any one here know how to print files from a folder in VBA?

I have a button on a form (in Access) that when clicked it goes out and
finds all the
files in a particular folder that pertain to that form's id. That's no
problem. But...

Once it's found all the files, I want to print each file. I can write the
loop, but I can't find the right command word to make them print. Help!

Dim i As Integer
For i = 1 To .FoundFiles.count
'Print each file
'Print .FoundFiles(i) <---- What is this line supposed to
be?????
Next i

Add the following at the start

Dim oDoc as Document

at your comment, include the following lines

Set oDoc = Documents.Open(.FoundFiles(i))
oDoc.PrintOut Background:=False
oDoc.Close SaveChanges:=wdDoNotSaveChanges

The code above assumes that you have set a reference to Word in Tools
References in your Access VBA project.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
L

Linc

Hey Jonathan,

Thanks for the help. The documents are actually .pdf's. Do you think I
could do basically the same thing only referencing the Adobe libraries? I'm
going to try...

Thanks again!
 
J

Jonathan West

Linc said:
Hey Jonathan,

Thanks for the help. The documents are actually .pdf's. Do you think I
could do basically the same thing only referencing the Adobe libraries?
I'm
going to try...

Thanks again!

I that case, I would suggest you use ShellExecute and apply the "print" verb
to the document.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
J

Jonathan West

Linc said:
Hey Jonathan,

Thanks for the help. The documents are actually .pdf's.

It helps to mention little details like that! As you posted in a Word VBA
group I made the understandable assumption that you were talking of Word
documents...

Do you think I
could do basically the same thing only referencing the Adobe libraries?
I'm
going to try...

Thanks again!

I that case, I would suggest you use the ShellExecute Windows API command
and apply the "print" verb
to the document.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
L

Linc

Actually I hoping to find a single Print command that would just do my
bidding and not care what kind of document it was. ;)

It looks like your ShellExecute might do the trick. Sorry about the
confusion, it's always the little details that get me.

Thanks again for the help. :)
 
L

Linc

Jonathan West said:
I that case, I would suggest you use ShellExecute and apply the "print" verb
to the document.


Ok, how do I use ShellExecute? Is there a library I have to open?
 
L

Linc

Jonathan, you rock!!!

I got the ShellExecute to work and I couldn't be happier! Time to quit
before I break something.

Have a good one.
Chris
 

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