#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"