Results 1 to 2 of 2

VB Compile Error - User-defined type not defined

Threaded View

  1. #1
    Registered User
    Join Date
    08-27-2010
    Location
    Torrance, CA
    MS-Off Ver
    Excel 2007
    Posts
    7

    VB Compile Error - User-defined type not defined

    We have a message box that pops up when we want to print and select whether we want to print to the printer or to Acrobat Distiller. It used to work to print to pdf just fine (provided you had previously selected Distiller selected as the default printer), but within the last week, we started getting the above VB Compile error when we select print to Distiller.

    When you click debug after getting this VB error message, the row that it goes right to is the row
    Dim MyPDF As PdfDistiller
    but when you scroll up, the one with the yellow highlight and the arrow that it bombs out on is the first row here:


    Function Print_To_PDF1(MyFrom As Integer, MyTo As Integer, PDF_Print As Boolean, PSFileName As String)
    '
    '
    Dim MyCurrentDir As String
    Dim MyPSFileName As String
    
    
    Dim MyCurrectDir As String, PDFFileName As String
    
    MyCurrentDir = "C:\Temp\Benefit Data Individuals\"
    
    PDFFileName = MyCurrentDir + PSFileName + ".pdf"
    MyPSFileName = MyCurrentDir + PSFileName + ".ps"
    
    If Dir(MyCurrentDir + PSFileName + ".ps") <> "" Then
    MsgBox "File Already Exist! " + PSFileName + ".ps"
    Exit Function
    End If
    
    If PDF_Print = True Then 'print to PDF if TRUE
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, printtofile:=True, _
    collate:=True, prtofilename:=MyPSFileName
    End If
    
    'convert postscript file to PDF
    Dim MyPDF As PdfDistiller
    Set MyPDF = New PdfDistiller
    MyPDF.FileToPDF MyPSFileName, PDFFileName, ""
    
    Set MyPDF = Nothing
    
    End Function

    When I asked online what might be wrong with the code, I was told

    Dim MyPDF As PdfDistiller
    PdfDistiller I don't believe is a system-defined type.


    As this is the row it first takes you to when you click debug, I am inclined to agree with the person, but I don't know how to "define" it or change the code to make it work.
    Also have no clue why it used to work and now it doesn't. Makes me think that some new VB/Excel changes have come out that is now caused the code to be "defunct?"

    I also had a suggestion from someone that said

    If you want to keep the code as it is you'll need a reference to the PDFDistiller DLL Library, Tools>References...

    Or you could try late-binding using CreateObject to create and reference an instance of Distiller.

    But I have no clue how to do either. Again, any help would be greatly appreciated.
    Last edited by dbwiz; 09-09-2010 at 07:32 PM. Reason: did not put code tags around the code

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1