Every day I create many Excel reports that I manually save as PDFs for
distribution to my stakeholders. I'd like to automate this process using a macro.
I've seen the following code online and have attempted to use it, but receive
an error in the Dim MyPDF line of code indicating that the user-defined type
is not defined.

I'm using Excel 2003 and Acrobat Distiller 8. I have no problem creating
PDFs manually


Sub Create_PDF()

Dim tempPDFFileName As String
Dim tempPSFileName As String
Dim tempPDFRawFileName As String
Dim tempLogFileName As String
Dim x As Integer
Dim ws As Worksheet
Dim PDFPath As String

ThisWorkbook.Worksheets(3).Select

For x = 3 To ThisWorkbook.Worksheets.Count
        If Worksheets(x).Visible = xlSheetVisible Then Worksheets(x).Select (False)
Next x

PDFPath = ActiveWorkbook.Path & Application.PathSeparator
tempPDFRawFileName = PDFPath & Left(Format(Date, "mm.dd.yyyy") & " " & wsAgenda.Range("I2"), Len(Format(Date, "mm.dd.yyyy") & " " & wsAgenda.Range("I2")))

tempPSFileName = tempPDFRawFileName & ".ps"
tempPDFFileName = tempPDFRawFileName & ".pdf"
tempLogFileName = tempPDFRawFileName & ".log"

ActiveWindow.SelectedSheets.PrintOut copies:=1, preview:=False, ActivePrinter:="Adobe PDF", printtofile:=True, Collate:=True, prtofilename:=tempPSFileName

Dim myPDF As PdfDistiller '<==== ERROR HERE: User-defined type not defined
Set myPDF = New PdfDistiller
myPDF.FileToPDF PSFileName, PDFFileName, ""

Kill tempPSFileName
Kill tempLogFileName

End Sud