J
Jmbostock
I've a bit of a problem. I have a routine that creates excel worksheet
then converts them into .PS files, and then into .PDF.
It works fine converting them into .PS files, but it keeps giving m
this error whenever it tries to convert the .PS into a .PDF:
Run-time error '-2147417851 (80010105)':
Method 'FileToPDF' of object 'IPdfDistiller' failed
I've got it to run before last quarter, but now this keeps happening.
can get one spreadsheet to work no problem, it's when the second shee
tries to run that the problem occurs.
Any ideas?
Thanks in Advance.
The shortened code is below:
Private Sub AEDoCommission()
Dim Quarter As String
Dim Year As Integer
Dim x As String
Dim Report As Workbook
Dim myName As String
Dim mycount As Integer
Dim copycount As Integer
Dim mynumber As Integer
Dim myRegion As String
Dim PSFileName As String
Dim PDFFileName As String
Dim myPDF As PdfDistiller
Set myPDF = New PdfDistiller
myName
Workbooks("AE_Statement.xls").Sheets("Statement").Range("Name").Value
myRegion
Workbooks("AE_Statement.xls").Sheets("Statement").Range("Region").Value
Quarter = Sheets("Statement").Range("Quarter").Value
Year = Sheets("Statement").Range("Year").Value
x = "NA Corp Commissions" & " " & Year & " " & Quarter & " "
"Hardcode"
j = x & ".xls"
g = "G:\Business Ops\James\Commission Summary\"
h = g & Quarter & " " & Year & "\" & x & ".xls"
i = Quarter & " " & Year
k = "TCVs-" & Quarter
t = Workbooks(j).Sheets("Ind Sum").Range("t").Value
s = Workbooks(j).Sheets("Ind Sum").Range("s").Value
PSFileName = "G:\Business Ops\James\Commission Summary\" & i
"\Statements\" & myRegion & "\" & myName & ".ps"
PDFFileName = "G:\Business Ops\James\Commission Summary\" & i
"\Statements\" & myRegion & "\" & myName & ".pdf"
Application.ScreenUpdating = True
ActiveWorkbook.SaveAs Filename:= _
"G:\Business Ops\James\Commission Summary\" & i
"\Statements\" & myRegion & "\" & myName & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Workbooks("TCV.xls").Save
Workbooks("TCV.xls").Close
'Application.DisplayAlerts = False
'Application.ActivePrinter = "Acrobat PDFWriter on LPT1:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"Acrobat PDFWriter", printtofile:=True, prtofilename:=PSFileName
myPDF.FileToPDF PSFileName, PDFFileName, ""
ActiveWorkbook.Clos
then converts them into .PS files, and then into .PDF.
It works fine converting them into .PS files, but it keeps giving m
this error whenever it tries to convert the .PS into a .PDF:
Run-time error '-2147417851 (80010105)':
Method 'FileToPDF' of object 'IPdfDistiller' failed
I've got it to run before last quarter, but now this keeps happening.
can get one spreadsheet to work no problem, it's when the second shee
tries to run that the problem occurs.
Any ideas?
Thanks in Advance.
The shortened code is below:
Private Sub AEDoCommission()
Dim Quarter As String
Dim Year As Integer
Dim x As String
Dim Report As Workbook
Dim myName As String
Dim mycount As Integer
Dim copycount As Integer
Dim mynumber As Integer
Dim myRegion As String
Dim PSFileName As String
Dim PDFFileName As String
Dim myPDF As PdfDistiller
Set myPDF = New PdfDistiller
myName
Workbooks("AE_Statement.xls").Sheets("Statement").Range("Name").Value
myRegion
Workbooks("AE_Statement.xls").Sheets("Statement").Range("Region").Value
Quarter = Sheets("Statement").Range("Quarter").Value
Year = Sheets("Statement").Range("Year").Value
x = "NA Corp Commissions" & " " & Year & " " & Quarter & " "
"Hardcode"
j = x & ".xls"
g = "G:\Business Ops\James\Commission Summary\"
h = g & Quarter & " " & Year & "\" & x & ".xls"
i = Quarter & " " & Year
k = "TCVs-" & Quarter
t = Workbooks(j).Sheets("Ind Sum").Range("t").Value
s = Workbooks(j).Sheets("Ind Sum").Range("s").Value
PSFileName = "G:\Business Ops\James\Commission Summary\" & i
"\Statements\" & myRegion & "\" & myName & ".ps"
PDFFileName = "G:\Business Ops\James\Commission Summary\" & i
"\Statements\" & myRegion & "\" & myName & ".pdf"
Application.ScreenUpdating = True
ActiveWorkbook.SaveAs Filename:= _
"G:\Business Ops\James\Commission Summary\" & i
"\Statements\" & myRegion & "\" & myName & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Workbooks("TCV.xls").Save
Workbooks("TCV.xls").Close
'Application.DisplayAlerts = False
'Application.ActivePrinter = "Acrobat PDFWriter on LPT1:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"Acrobat PDFWriter", printtofile:=True, prtofilename:=PSFileName
myPDF.FileToPDF PSFileName, PDFFileName, ""
ActiveWorkbook.Clos