• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 893
  • Last Modified:

Print any file type from VBA

I have a listbox with all the files in a directory.  These are mixed files types, workd, pdf, excel, etc.  Is there a way, when the user highlights the file name in the listbox and then hits print, to simply print the file without having to open it or use any type of object?  This is from an Access 2003 form in VBA.  The file types can also be 2003, 2007 or 2010 files.

Sandra
0
Sandra Smith
Asked:
Sandra Smith
  • 3
2 Solutions
 
Jeffrey CoachmanMIS LiasonCommented:
try this.

Note that certain file won't just "print" using this.
It will depend on what application you have associated with the file extension

ex PDF's will sometimes keep the Adobe reader app open.

Basic code from here:
 http://www.mvps.org/access/api/api0018.htm
Access-EEQ27824846PrintFileFromV.mdb
0
 
Jeffrey CoachmanMIS LiasonCommented:
If it were me, I would just open the folder in a web browser control.

Then you can print the file normally, (simply by right-clicking the file and selecting "Print")
This technique should always work.

Modified sample attached
Access-EEQ27824846PrintFileFromV.mdb
0
 
Sandra SmithRetiredAuthor Commented:
Good information on both.  I finally told the user when they open the file, simply print from there.  Since they so rarely print I found out, this was the best way to solve the problem.

Sandra
0
 
Jeffrey CoachmanMIS LiasonCommented:
OK,
Enjoy the weekend
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now