Ghostscript Error 1007 Merge operation from MS Access 2003

General usage of the PDF Printer.

Moderator: jr

Post Reply
dudley
Posts: 8
Joined: Mon Jun 02, 2008 4:46 pm

Ghostscript Error 1007 Merge operation from MS Access 2003

Post by dudley »

I'm testing the Merge process by trying to send multiple Access reports. I've modified the sample code for PrintReportAsPDF to allow me to pass variables about the report to create, whether to open it once completed, and whether to merge. The first report is created just fine, I get the bubble message saying it's done, and if I'm only sending one (no merge) it opens and looks fine. But when the later ones are sent, I get the 1007 error. The icon in the tray indicates there's a merge in process, but the error window comes up and it fails. When I open the PDF file, it only holds the first report. I downloaded 5.0.609 this morning, but I get the same results. I sure appreciate any help or feedback!

Here's the code that calls bullzip:
Case "PDF"
'Make sure any previous instances of BullZip are finished
Do While Dir(Environ("APPDATA") & "\Bullzip\PDF Printer\runonce@Bullzip PDF Printer.ini") <> ""
' c = c + 1
' Sleep 200
Loop

Select Case intRptCounter
Case 1 'First one, make it
If gintRptCount = 1 Then 'If it is the only one then make it, no append, display it
Call PrintReportAsPDF(gstrNewReport, "Yes", "No")
Else 'make it, but don't display it, no merge 'cause it's the first
Call PrintReportAsPDF(gstrNewReport, "No", "No")
End If
Case gintRptCount 'last rpt, merge/append it, then display it
Call PrintReportAsPDF(gstrNewReport, "Yes", "Yes")
Case Else 'Second or later - merge/append it, don't open it
Call PrintReportAsPDF(gstrNewReport, "No", "Yes")

End Select
End Select





Sub PrintReportAsPDF(RPTName As String, ShowPDF As String, Merge As String)
Dim pdf_printer_name As String
Dim pdf_printer_index As Integer
Dim current_printer_name As String
Dim current_printer_index As Integer
Dim i As Integer
Dim progid As String
Dim xmldom As Object
Dim currentdir As String
Dim pdfwriter As Object
Dim c As Integer

Rem -- Get the directory of the database
currentdir = GetDatabaseFolder

Rem -- Read the info xml
' Set xmldom = CreateObject("MSXML.DOMDocument")
' xmldom.Load (currentdir & "\info.xml")

Rem -- Get the program id of the automation object.
' progid = xmldom.SelectSingleNode("/xml/progid").Text

Rem -- Create the printer automation object
Set pdfwriter = CreateObject("Bullzip.PDFPrinterSettings")

Rem -- Printer specific settings
pdf_printer_name = pdfwriter.GetPrinterName

Rem -- Find the index of the printer that we want to use
pdf_printer_index = -1
current_printer_index = -1
current_printer_name = Application.Printer.DeviceName
For i = 0 To Application.Printers.count - 1
If Application.Printers.Item(i).DeviceName = pdf_printer_name Then
pdf_printer_index = i
End If
If Application.Printers.Item(i).DeviceName = current_printer_name Then
current_printer_index = i
End If
Next

Rem -- Exit here if the pdf printer was not found
If pdf_printer_index = -1 Then
MsgBox "The printer '" & pdf_printer_name & "' was not found on this computer."
Exit Sub
End If

Rem -- Exit here if the current printer was not found
If current_printer_index = -1 Then
MsgBox "The current printer '" & current_printer_name & "' was not found on this computer." & _
" Without this printer the code will not be able to restore the original printer selection."
Exit Sub
End If

Rem -- Set the printer
Application.Printer = Application.Printers(pdf_printer_index)

Rem -- Configure the PDF printer
With pdfwriter

Rem -- Set the destination file name of the PDF document
' .SetValue "output", GetDatabaseFolder & "LSP_ScaleReport.pdf"
Select Case Merge
Case "No"
.setvalue "output", "<personal>\" & "LSP_Scale_Report_" & "<date>" & ".pdf"
Case "Yes"
.setvalue "MergeFile", "<personal>\" & "LSP_Scale_Report_" & "<date>" & ".pdf"
End Select

Rem -- Control the dialogs when printing
.setvalue "ConfirmOverwrite", "no"
.setvalue "ShowSaveAS", "never"
.setvalue "ShowSettings", "never"
.setvalue "ShowPDF", ShowPDF

Rem -- Set document properties
.setvalue "Target", "printer"
.setvalue "Title", "LSP Scales Report"
.setvalue "Subject", "Report generated at " & Now

Rem -- Display page thumbs when the document is opened
.setvalue "UseThumbs", "no"

Rem -- Set the zoom factor to 50%
.setvalue "Zoom", "50"

Rem -- Place a stamp in the lower right corner
' .SetValue "WatermarkText", "LSP Report"
' .SetValue "WatermarkVerticalPosition", "bottom"
' .SetValue "WatermarkHorizontalPosition", "right"
' .SetValue "WatermarkVerticalAdjustment", "3"
' .SetValue "WatermarkHorizontalAdjustment", "1"
' .SetValue "WatermarkRotation", "0"
' .SetValue "WatermarkColor", "#ff0000"
' .SetValue "WatermarkOutlineWidth", "1"

Rem -- Write the settings to the runonce.ini file
.WriteSettings True

End With

Rem -- Run the report
DoCmd.OpenReport RPTName

End Sub
Post Reply