User type not defined error!

merveak

New Member
Joined
Jan 20, 2016
Messages
12
I use VBA code to create and save pdf file however I receive error :"user type not defined "

The highlighted line like the following;
Dim pdfjob As PDFCreator.clsPDFCreator

PDF creator is already set as a reference. The code works on another computer with Excel 2003, however not working on my computer (excel 2013).

Any help is appreciated!

Code:
Sub PrintToPDF_Early()
'Author       : Ken Puls ([URL="http://www.excelguru.ca"]Excelguru Help Site - Welcome[/URL])
'Macro Purpose: Print to PDF file using PDFCreator
'   (Download from [URL="http://sourceforge.net/projects/pdfcreator/"]PDFCreator | SourceForge.net[/URL])
'   Designed for early bind, set reference to PDFCreator
 
    Dim pdfjob As PDFCreator.clsPDFCreator
    Dim sPDFName As String
    Dim sPDFPath As String

    '/// Change the output file name here! ///
    If UserForm1.TextBox4.Text <> "" Then
    sPDFName = "AKSAN" & "_" & UserForm1.TextBox4.Text & "_" & UserForm1.TextBox7.Text & "_" & UserForm1.TextBox5.Text & "_" & UserForm1.tarih11.Text & ".pdf"
    Else
    sPDFName = "AKSAN" & "_" & UserForm1.ComboBox6.Text & "_" & UserForm1.TextBox7.Text & "_" & UserForm1.TextBox5.Text & "_" & UserForm1.TextBox5.Text & "_" & UserForm1.tarih11.Text & ".pdf"
    nlef = Left(sPDFName, 4)
nrig = Left(sPDFName, 4)
    End If
    
    
    sPDFPath1 = ActiveWorkbook.Path & "\giden\"
    sPDFPath = ActiveWorkbook.Path & "\bugun\" '"C:\Documents and Settings\ksy05\Desktop\ramo\bugun\"
'/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/
  
'/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/
    'Check if worksheet is empty and exit if so
    If IsEmpty(ActiveSheet.UsedRange) Then Exit Sub

    Set pdfjob = New PDFCreator.clsPDFCreator

    With pdfjob
        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") = sPDFPath
        
        
        .cOption("AutosaveFilename") = sPDFName
        .cOption("AutosaveFormat") = 0    ' 0 = PDF
        .cClearCache
    End With
 

    'Print the document to PDF
    Sheets("form").PrintOut copies:=1, ActivePrinter:="PDFCreator"

    'Wait until the print job has entered the print queue
    Do Until pdfjob.cCountOfPrintjobs = 1
        DoEvents
    Loop
    pdfjob.cPrinterStop = False

    'Wait until PDF creator is finished then release the objects
    Do Until pdfjob.cCountOfPrintjobs = 0
        DoEvents
    Loop
    pdfjob.cClose
    Set pdfjob = Nothing
End Sub
 
Last edited by a moderator:

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
If the correct reference is set (and isn't flagged as MISSING) then you shouldn't get that error. Do you have PDF Creator installed on both machines?
 
Upvote 0
Yes it is installed on both machines.

On my machines it is flagged as "PDF Creator-Your OpenSource Pdf Solution", on other computer it is flagged as "PDF Creator". Does it make any difference?
 
Upvote 0
That would tend to suggest that it is not exactly the same reference. It may be that the class has changed - did you try Andrew's suggestion?
 
Last edited:
Upvote 0
That would tend to suggest that it is not exactly the same reference. It may be that the class has changed - did you try Andrew's suggestion?

Yes. this time another error appeared "sub or function not defined"

related row is ;

Call PrintToPDF_Early
 
Upvote 0
The procedure in the link I posted was named PrintToPDF_Late.

Sorry, I copied the code from attached post to my workbook.
Now received another error: run time error 429
problem is the following row;
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,021
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top