Download and install Cute PDF-Writer (http://www.cutepdf.com/)
It installs as a printer. Now, you can write any documents (Excel, Word,
various pictures, web pages, etc. to PDF format. Simply open the document,
select Print from menu, select CutePDF Printer, and when you click on Print
button, a file save dialog opens.
Arvi Laanemets
<cv...@mycaf.com> wrote in message
news:1140463544.1...@g43g2000cwa.googlegroups.com...
Hope this helps.
Pete
--
Dave Peterson
Pete
These things can not be recorded in macros, you have to cut the
code manually.
Adobe Acrobat offers a COM interface to the VBA programmer; it's pretty
expensive. Alternatively, the latest version of PDFCreator now also
provides a COM interface and the distribution file includes examples.
Here is a skeleton (taken from actual working code, but not tested
in this incarnation):
Option Explicit
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Sub PrtPDFCreator(theObject As Object)
' Print to the PDFCreator printer
' Needs a reference to PDFCreator.exe
Const theFileRoot As String = "C:\Temp\PDFs\" ' Testing (must exist)
Dim outName As String
Dim strOldPrinter As String
' Add a reference to PDFCreator
Dim myPDFCreator As PDFCreator.clsPDFCreator
outName = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) & "-" _
& Application.ActiveSheet.Name & "-" _
& Format((Now), "HHNN-SS") & Format((Timer() * 100) Mod 100, "00") & ".PDF"
Set myPDFCreator = New PDFCreator.clsPDFCreator
With myPDFCreator
If .cStart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + vbOKOnly, "PrtPDFCreator"
Exit Sub
End If
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = theFileRoot
.cOption("AutosaveFilename") = outName
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cClearCache
End With
' Perform the print action
strOldPrinter = ActivePrinter
theObject.PrintOut ActivePrinter:="PDFCreator"
' Wait until the print job has entered the queue
Do Until myPDFCreator.cCountOfPrintjobs = 1
DoEvents
Sleep 100
Loop
Sleep 100
myPDFCreator.cPrinterStop = False
' Wait until the PDF file shows up
Do Until Dir(theFileRoot & outName) <> ""
DoEvents
Loop
myPDFCreator.cClose
Set myPDFCreator = Nothing
Sleep 100
DoEvents
ActivePrinter = strOldPrinter
End Sub
Private Sub myPDFCreator_eError()
MsgBox "ERROR [" & myPDFCreator.cErrorDetail("Number") & "]: " _
& myPDFCreator.cErrorDetail("Description"), vbCritical + vbOKOnly, "PrtPDFCreator"
End Sub
Sub testPDFCreator()
Dim mySheet As Worksheet
For Each mySheet In ActiveWorkbook.Sheets
mySheet.Activate
Call PrtPDFCreator(mySheet)
Next mySheet
MsgBox "Done."
End Sub
--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"