ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel - PDF (https://www.excelbanter.com/excel-programming/276056-re-excel-pdf.html)

Jim Rech

Excel - PDF
 
This is a technique that worked for me using Acrobat 5.0. The PDFWriter
driver will look in the registry in a special spot for a file name, and use
it if it's found. Else it prompts the user. Whether this works for any
other versions of Acrobat I don't know.

Now I assume by "saving to a PDF file" you meant "printing to a PDF file",
right? So you have to have set the active printer to the PDFWriter driver
before running this. Btw, the driver itself cleans up the registry.

--
Jim Rech
Excel MVP

Public Const HKEY_CURRENT_USER = &H80000001

Declare Function RegCreateKeyA Lib "ADVAPI32.DLL" _
(ByVal hkey As Long, _
ByVal sKey As String, _
ByRef plKeyReturn As Long) As Long

Declare Function RegCloseKey Lib "ADVAPI32.DLL" _
(ByVal hkey As Long) As Long

Declare Function RegSetValueExA Lib "ADVAPI32.DLL" _
(ByVal hkey As Long, _
ByVal sValueName As String, _
ByVal dwReserved As Long, _
ByVal dwType As Long, _
ByVal sBuffer As String, _
ByVal dwLen As Long) As Long

Sub PDF_Print_NoPrompt()
SetRegistryValue HKEY_CURRENT_USER, "Software\Adobe\Acrobat PDFWriter",
_
"PDFFileName", "c:\YourFileNameHere.PDF"
ActiveSheet.PrintOut
End Sub

Sub SetRegistryValue(KEY As Long, SubKey As String, _
ValueName As String, NameValue As Variant)
Dim KeyHdlAddr As Long
If RegCreateKeyA(KEY, SubKey, KeyHdlAddr) = 0 Then
RegSetValueExA KeyHdlAddr, ValueName, 0&, _
1, NameValue, Len(NameValue)
RegCloseKey KeyHdlAddr
End If
End Sub




All times are GMT +1. The time now is 11:41 AM.

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