Print files from Access

  • Thread starter Thread starter Sean
  • Start date Start date
S

Sean

Dear All,

In my DB there's a table of documents/images and I need to add a print
button that will print the document out using the program associated to the
file extension. Even if I can output the more common formats (DOC, XLS and
PDF) that would be "hugely" beneficial for me.

Any ideas?

Thanks, S.
 
Each type of doc requires a different code. So you'd need to get the code
for each type of doc and then build a case statement to check which file
extension is associated with the current doc and run the appropriate code.
An alternative would be to use the followhyperlink to open the doc and let
the user do the printing (just a thought, they can then change the printer,
make changes to setting draft-quality, double-sided...).

To print word docs something like the following should work
strObjectPath = "P:\2004worksheets\IIS_WS.doc"

Set oWord = New Word.Application
oWord.Documents.Add (strObjectPath)
oWord.PrintOut
oWord.Quit SaveChanges:=0
Set oWord = Nothing

To print Excel files try
Dim XLApp As New Excel.Application
Dim FileName As String

FileName = "C:\Test.xls"

XLApp.Workbooks.Open FileName
XLApp.Worksheets.PrintOut
XLApp.Quit

For pdfs, acording to the help that I have found you can do this with
command line switches 'AcroRd32.exe /p filename'. So using the shell command
you should be able to print any pdf out using this technique.

Don't forget your references or late binding.

Daniel
 

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

Back
Top