Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm running the following script to combine multiple pdf files into one using PDFCreator. The problem is when you get to the part where the files are loaded into PDFCreator, Adobe Reader opens (no actual file is opened in it), and the next file will not load into the PDFCreator queue until Adobe Reader is closed. Is there a simple method of closing Adobe Reader in that loop? Or somehow send the pdfs into PDFCreator 'ghostlike' without initiating an instance of Adobe Reader to begin with?
Sub bindPDF() Dim pdfjob As PDFCreator.clsPDFCreator Dim sPDFName As String Dim sPDFPath As String Dim DefaultPrinter$ Dim bRestart As Boolean Dim ws As Worksheet, itemrange As Range, cell As Range, itemcount As Integer Set ws = ActiveSheet Set itemrange = ws.Range("e1:e18") Dim sFilenames() As String For Each cell In itemrange itemcount = itemcount + 1 ReDim Preserve sFilenames(itemcount - 1) sFilenames(itemcount - 1) = cell.Value Next cell '/// Change the output file name here! /// sPDFName = "SCRAServicemembersCivilReliefAct.pdf" '' stub here sPDFPath = "\\csafsusers1\users\dyerm\Desktop\Brown - 1010557007\Documents\Black Knight\" 'Activate error handling and turn off screen updates On Error GoTo EarlyExit ' Application.ScreenUpdating = False Set pdfjob = New PDFCreator.clsPDFCreator 'Check if PDFCreator is already running and attempt to kill the process if so Do bRestart = False Set pdfjob = New PDFCreator.clsPDFCreator If pdfjob.cStart("/NoProcessingAtStartup") = False Then 'PDF Creator is already running. Kill the existing process Shell "taskkill /f /im PDFCreator.exe", vbHide DoEvents Set pdfjob = Nothing bRestart = True End If Loop Until bRestart = False 'Assign settings for PDF job With pdfjob .cOption("UseAutosave") = 1 .cOption("UseAutosaveDirectory") = 1 .cOption("AutosaveDirectory") = sPDFPath .cOption("AutosaveFilename") = sPDFName .cOption("AutosaveFormat") = 0 ' 0 = PDF DefaultPrinter = .cDefaultPrinter .cDefaultPrinter = "PDFCreator" .cClearCache End With 'Delete the PDF if it already exists If Dir(sPDFPath & sPDFName) = sPDFName Then Kill (sPDFPath & sPDFName) 'Print the document to PDF With pdfjob ' change this filename each loop '*****This is where the thing is happening**** For i = 0 To UBound(sFilenames) .cPrintFile (sFilenames(i)) 'Application.Wait Now + TimeValue("0:0:2") Next i 'Wait until all the print jobs have entered the queue Do Until pdfjob.cCountOfPrintjobs = UBound(sFilenames) + 1 DoEvents Loop .cCombineAll .cPrinterStop = False End With 'Wait until the PDF file shows up then release the objects Do Until pdfjob.cCountOfPrintjobs = 0 DoEvents Loop 'Wait a bit longer for PDF Creator to finish Application.Wait Now + TimeValue("0:0:2") 'reset original Windows' default printer pdfjob.cDefaultPrinter = DefaultPrinter pdfjob.cClose Cleanup: 'Release objects and terminate PDFCreator Set pdfjob = Nothing Shell "taskkill /f /im PDFCreator.exe", vbHide On Error GoTo 0 'Application.ScreenUpdating = True Exit Sub EarlyExit: 'Inform user of error, and go to cleanup section MsgBox "There was an error encountered. PDFCreator has" & vbCrLf & _ "has been terminated on file " & sPDFName & " in bind. Please try again.", _ vbCritical + vbOKOnly, "Error" Resume Cleanup End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Matthew,
I believe PDFCreator has a SDK for doing this. You need to consult its user guide to see how to automate it 'behind-the-scenes' and only display the finished file for review. IIRC, you'll need to get the window handle of the 1st running instance of PDFCreator and set an object ref to it; -use that instance throughout. (I can help with the required code) Once you've got all your files consolidated into one, display (and release) the PDFCreator instance so you can review the job. Then you can close PDFCreator in the normal fashion -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry.., I was thinking of another app I used some years back with a
similar name! I downloaded the free version so I could view its user guide. This looks like an interesting supplement to Excel's built-in "ExportToFixedFormat" feature for peaople who don't have anything like Adobe Acrobat. (Their PDF Architect app look promising!) -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I get rid of Adobe Reader icon? | Excel Discussion (Misc queries) | |||
Opening a .pdf file with Adobe Reader 8.0 | Excel Programming | |||
Opening a pdf file with Adobe Reader | Excel Programming | |||
how i can take file from adobe reader and make it read with micr. | Excel Discussion (Misc queries) | |||
Identifying version of Adobe Reader | Excel Programming |