View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
[email protected] horkuang@horkuang.com is offline
external usenet poster
 
Posts: 8
Default print PDF file from Excel - NOT print Excel to PDF?

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

Alan Ibbotson wrote:
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