Thread: PDF button
View Single Post
  #2   Report Post  
William
 
Posts: n/a
Default

Hi Kwanjangnim

If you cannot currently create a pdf file manually, you need to go to this
site and set everything up.
http://www.rcis.co.za/dale/info/pdfguide.htm

Then, attach this macro to a button on one of your toolbars

Sub PrintActiveSheetAsPDF()
'Set a reference to Acrobat Distiller
Dim PSFileName As String, PDFFileName As String
Dim myPDF As PdfDistiller, x As String, y As String
Dim wb As Workbook, iprinter As String, ws As Worksheet
iprinter = Application.ActivePrinter

'Amend as appropriate
Application.ActivePrinter = "Adobe PDF on Ne02:"

Set wb = ActiveWorkbook
Set ws = wb.ActiveSheet

'Where to save the pdf file
If wb.Path = "" Then
x = CreateObject("WScript.Shell").SpecialFolders("Desk top") & "\"
y = wb.Name
Else
x = wb.Path & "\"
y = Left(wb.Name, Len(wb.Name) - 4)
End If
PSFileName = x & y & ".ps"
PDFFileName = x & y & ".pdf"

'Print the file
ws.PrintOut , prtofilename:=PSFileName
Set myPDF = New PdfDistiller
myPDF.FileToPDF PSFileName, PDFFileName, ""

'Clean up
On Error Resume Next
Kill Left(PSFileName, Len(PSFileName) - 2) & "log"
Kill PSFileName
Application.ActivePrinter = iprinter

'Amend as appropriate to open the file
Shell "C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe " +
PDFFileName, 1
End Sub
--


XL2003
Regards

William



"Kwanjangnim" wrote in message
...
hi all, i'd like to create a button on my worksheet that will create a pdf
file of the current worksheet when pressed, can this be done?