ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   print PDF file from Excel - NOT print Excel to PDF? (https://www.excelbanter.com/excel-programming/380140-print-pdf-file-excel-not-print-excel-pdf.html)

Alan Ibbotson[_2_]

print PDF file from Excel - NOT print Excel to PDF?
 
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



[email protected]

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




All times are GMT +1. The time now is 02:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com