Page 1 of 1

Error 1007 Merge

Posted: Wed May 28, 2008 8:30 pm
by jobrahms
Hi, I'm trying to merge two pdfs from within access vba and I keep getting this error:

Error 1007: An error occured while running Ghostscript

Merge Operation

... and then the bullzip settings form comes up. Anyone know why this is happening?

Here is my code:

progid = "bullzip.PDFPrinterSettings"

Set pdfwriter = CreateObject(progid)

With pdfwriter
.SetValue "output", fullPath
.SetValue "ShowSaveAS", "never"
.SetValue "ShowSettings", "never"
.SetValue "ShowPDF", "no"
.SetValue "Target", "printer"
.SetValue "Title", "Cut Report"
.SetValue "Subject", "Report generated at " & Now
.SetValue "UseThumbs", "yes"
.SetValue "MergeFile", "C:\testdumb.pdf" 'summaryPath
.WriteSettings True
End With

... open the report, etc.

Thanks

Posted: Sun Jun 01, 2008 8:41 am
by jr
Just a couple of questions.

1) Please confirm that you are using the latest version.
2) Does the error message tell you anything else?
3) Is the testdumb.pdf created by the Bullzip PDF Printer?

Regards,
Jacob

I'm having the same problem

Posted: Mon Jun 02, 2008 5:01 pm
by dudley
I'm having the same problem. I'm testing the Merge process by trying to send two 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 second one is 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
Call PrintReportAsPDF(gstrNewReport, "No", "No")
Case gintRptCount 'last rpt, display it
Call PrintReportAsPDF(gstrNewReport, "Yes", "Yes")
Case Else
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

Posted: Tue Jun 03, 2008 11:38 pm
by dudley
Some more details to supplement my post:
The error message box says: An error occurred. Error 1007: An error occurred while running Ghostscript. Merge operation.

Also, I've adjusted the section of code that determines which version of the command line to run:
...Select Case for type of report, last option:
Case "PDF"
Select Case intRptCounter 'variable holds the position of the report
Case 1 'First one, make it
If gintRptCount = 1 Then 'gintrptcount holds total rpts (pages) there will be, so if only 1, then make it and display it, no merge
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 page, but not last - merge/append it, don't open it
Call PrintReportAsPDF(gstrNewReport, "No", "Yes")
End Select

I've been trying to get information about this error in Ghostscript, but to no avail.

Can anyone help with this?

Posted: Wed Aug 13, 2008 9:49 am
by dibidibi
As so many I had the same problem, but I believe here is the solution, proven on a few configurations:
During installation of BullZip, it looks for GhostScript, if not found, it downloads/installs GhostscriptLight in the sub-folder 'gs'.
If an existing installation of GhostScript is found, it will configure itself to use that instance.
Now, the GhostScriptLight seems to be the problem: it merges well trough the GhostScript interface, but it doesn't do the merge from code.

Solution:
1. Uninstall BullZip, and remove the folder c:\program Files\ghostscript completely to remove any 'remainings'.
2. Download/Install Ghostscript in it's default destination folder
3. Download/Install BullZip in it's default destination folder

You will find the sub-folder 'gs' under BullZip to be empty, implying that BullZip will use the ghostscript instance you installed previously.
The merge-action from code now works perfectly!
(be sure to use the lastest versions of both BullZip and GhostScript, I don't know if it would work in the other case)

PS: If merging to a PDF in a loop where you have just created the page you appending to, put in a delay of about 2 seconds in between...

That's it! Thank you!

Posted: Sat Aug 16, 2008 6:55 am
by dudley
Dibidibi,
I can't thank you enough for going out of your way to tell me how to fix my problem. This is huge for me. Thank you Thank you Thank you.

Re: the delay: I'm using the following after printing the Access report, before moving on to the next one and it seems to work fine:

[code] Do While Dir(Environ("APPDATA") & "\Bullzip\PDF Printer\runonce@Bullzip PDF Printer.ini") <> ""
Loop
[/code]

Thanks again!
-Dudley

Re: Error 1007 Merge

Posted: Tue Feb 03, 2009 2:03 pm
by tolux
I have this error too.
I make thist steps:
uninstall gslite
uninstall BullZip
remove anything "bullzip" and "gs" from registry trough regedit
restart PC
download latest version gslite and BullZip PDF Printer
install gslite
install Bullzip

I still obtained message "Error 1007: An error occured while running Ghostscript"

Grrrrr :-(

I have solution: Do not merge document in directory with special national characters (like czech characters with graphic accent, special characters from codepage 1250).

Error in Bullzip

Posted: Mon Feb 08, 2010 2:19 pm
by javarose
Hi,

I got this error when i try to use Bullzip.PDFPrinterSettings...

Bullzip (0x800A03E8)

Error writing settings file '\PDF Writer\Bullzip PDF Printer\runonce.ini'. Error 76: (WRTFILE) Path not found

Thanks in Advance