Hi, I have below code which works perfectly when i run the code manually. But now i am trying to run this code in task scheduler when i am logged off from client. Task scheduler is already running other codes successfully. Task scheduler starts this code but then do not complete the run and gets stuck somewhere which i cant see as i am client and it runs on server. I am wondering if something is wrong with Acrobat Distiller or AcrobatPDFMakerX references which do not allow "FiletoPDF" when user is logged off. Your help will be much appreciated.thanks.
Code to Print to pdf is
"
Private appDist As cAcroDist
Sub Printer()
Dim ReportPath As String, FName As String
ReportPath = DNU.Cells(1, 2)
sPDFVersionAndPort = "CutePDF Writer on CPW2:"
Set appDist = New cAcroDist
FName = "Data Report"
PSName = ReportPath & FName & ".ps"
PDFName = ReportPath & FName & ".pdf"
PrintPDF sPDFVersionAndPort, PSName, PDFName
ThisWorkbook.Close True
End Sub
Sub PrintPDF(ByVal sPDFVersionAndPort As String, ByVal sPSFileName As String, ByVal sPDfFileName As String, _
Optional ByVal sJobOptions As String)
Dim LogName As String
If Dir(sPSFileName) <> "" Then Kill sPSFileName
Debug.Print sPDfFileName
If Dir(sPDfFileName) <> "" Then Kill sPDfFileName
ALL_BONDS.Select
ActiveWindow.SelectedSheets.PrintOut ActivePrinter:=sPDFVersionAndPort, _
PrintToFile:=True, PrToFileName:=sPSFileName 'Prints to PS
Call appDist.odist.FileToPDF(sPSFileName, sPDfFileName, sJobOptions)
Kill sPSFileName 'Removes PS
LogName = Left(sPSFileName, Len(sPSFileName) - 2) & "log"
If Dir(LogName) <> "" Then Kill LogName
End Sub
"
Also there is a class module which has below code
''requires references:Acrobat Distiller; AcrobatPDFMakerX
Option Explicit
Public WithEvents odist As PdfDistiller
Private Sub Class_Initialize()
Set odist = New PdfDistiller
End Sub
Bookmarks