View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
chemburkar chemburkar is offline
external usenet poster
 
Posts: 1
Default "Application-defined or object-defined error" while printing excel report


I am creating a .pdf file from excel file The code works fine for smal
number of files ,but for 5,000-6,000 files the VBA code fails givin
error 1004
"Application-defined or object-defined error"

Here is the code snippet

'runs macro in xls file
Call runMacro()

'create postscript file (1)
Application.ActiveWindow.SelectedSheets.PrintOu
ActivePrinter:=printer, PrintToFile:=True, PrToFileName:=PSFileName

Dim PDFFileName AS String
'get pdf file name (2)
PDFFileName = publishInfo.publishReportPath & Filename


Dim PdfDistillerObj As Object
Set PdfDistillerObj = CreateObject("PdfDistiller.PdfDistiller.1")

' create the pdf report from the ps report.
PdfDistillerObj.FileToPDF strMenuFilePS, PDFFileName , ""
Set PdfDistillerObj = Nothing


If I run it in the debug mode
The code completes (1) and creates .ps file but before reaching (2
i.e. before creating the PDF filename it fails giving 1004 error

I am guessing that it could be memory issue as it fails only for larg
number of files, but not sure.

Any help appreciated.
Thanks in advnace

Meghan

chemburka
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message353955.htm