print PDF file from Excel - NOT print Excel to PDF?

A

Alan Ibbotson

I have a column that has catalog items in it. My plan is to have the macro
read each catalog item and then print out a corresponding MSDS (material
data safety sheet) that is located on a server in a PDF format.

Is it possible to open the PDF file using VBA and print it? I would prefer
if this all took place unseen, maybe the only thing seen would be the print
dialog, to set number of copies.

Thanks for any help,

Alan Ibbotson
 
H

horkuang

Alan,
I'd use the API ShellExceute here. That way you can leave the OS to
decide which app should print the file. Not tested, but something like
this :

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA"
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As
String, ByVal lpParameters As String, ByVal lpDirectory As String,
ByVal nShowCmd As Long) As Long

Dim RetVal As Long
RetVal = ShellExecute(&O0, "print", Range("A1").Value, vbNullString,
ThisWorkbook.Path, &O0)

if retval<=32 then
msgbox "Couldn't print: See
http://www.allapi.net/apilist/ShellExecute.shtml"
else
'OK, continue
end if

NickHK
 

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