Page 1 of 1

Still get dialog box

Posted: Fri Aug 31, 2007 11:40 pm
by bjones
I want to automate the creation of reports after hours by not displaying dialog boxes (some run for 3 hours). I have the program create the runonce.ini file (to set the output folder) with the following:

ConfirmOverwrite=no
DisableOptionDialog=yes
Output=C:\Reports\2007-08-31\DailyStatistics.pdf
ShowPDF=no
ShowSaveAS=never
ShowSettings=never

I just want it to create the PDF file with no interaction, however it still brings up the Print Range dialog box and stops. Is there a setting I have missed that will prevent this dialog box from popping up? It sits and waits all night until someone comes in and clicks the OK button. I would just like to streamline the process more.

I think the problem is in using of unicode

Posted: Tue Sep 18, 2007 2:35 pm
by bowman
I had the same problem while creating a runonce.ini file by using method CreateTextFile of Scripting.FileSystemObject. In this case WriteLine output is unicode, you can check it in any Hex viewer.
So, my solution was to use the method OpenAsTextStream of Scripting.FileSystemObject.
For example:
objFSO.CreateTextFile RUNONCE_FILENAME, ForWriting, True
Set objFile = objFSO.GetFile(RUNONCE_FILENAME)
Set objStream = objFile.OpenAsTextStream(ForWriting, TristateFalse)
objStream.WriteLine "[PDF Printer]"
..........
objStream.Close

Hope my post will help you

Posted: Tue Oct 02, 2007 10:04 am
by rewind
Having the same issue - getting a dialog when printing. I'm setting the contents of the runonce.ini from an external program using the winapi setprofilestring method. The contents of the file are the following:

[PDF Printer]
ShowSaveAS=never
ShowSettings=never
ConfirmOverwrite=no
Output=c:\test.pdf

After a print I can see that the runonce.ini file still exist suggesting bullzip never actually gets to it. The path to the appdata env variable on the test machine is: "C:\Documents and Settings\test.TESTDOM\Application Data" which is where I create the runonce.ini file. Could it be the path that is not read correct?

Another question. Is it required that the global.ini and settings.ini files exist (I have only created runonce.ini)?

----------------
EDIT: FIXED. Did not use bullzip subfolder in appdata dir. Thanks for a very nice program :)

Posted: Tue Oct 02, 2007 10:24 am
by bowman
Put runonce.ini file to:
%APPDATA%\Bullzip\PDF Printer\
It should work without global.ini and settings.ini files

Hint

Posted: Mon Oct 22, 2007 4:22 pm
by giulio
I was having the same problem, and this is the solution I found:

(I think a VBA example is better than many words)

N.B. Don't forget to put a reference on Bullzip in your project!

=============================

Public Function SetBullZipOutput(sFileName As String) As Boolean
Dim objBullZip As Bullzip.PDFPrinterSettings

On Error GoTo HandleErr


If sFileName <> "" Then ' First time set output
Set objBullZip = New Bullzip.PDFPrinterSettings
objBullZip.Init
objBullZip.LoadSettings

Call objBullZip.SetValue("Output", sFileName)
Call objBullZip.SetValue("ShowSettings", "never")
Call objBullZip.SetValue("ShowPDF", "no")
Call objBullZip.SetValue("ShowSaveAS", "nofile")
objBullZip.WriteSettings
Else
'Second time: wait until print is done
While Dir(Environ("APPDATA") & "\runonce.ini") <> ""
DoEvents
Wend
End If

Exit Function


HandleErr:
Select Case Err.Number
Case Else
If MsgBox("Error " & Err.Number & ": " & Err.Description & vbCrLf & "Retry?", vbYesNo, "SetBullZipOutput") = vbYes Then
Resume
End If
End Select


End Function

===========================
Must call this function before and after printing, like:

Function PDFPrint() As String
Dim FileName As String
Dim OldPrinter As String

FileName = ActiveDocument.Path & "\" & ActiveDocument.Name
If UCase(Right(FileName, 4)) = ".DOC" Or UCase(Right(FileName, 4)) = ".DOT" Then
FileName = Left(FileName, Len(FileName) - 4)
End If

FileName = FileName & ".PDF"

PDFPrint = FileName

If Dir(FileName) <> "" Then
If MsgBox("WARNING: PDF EXISTS" & Chr(13) & "YES=Keep file NO=OVERWRITEfile", vbYesNo, "WARNING") = vbYes Then
Exit Function
End If
End If
OldPrinter = ActivePrinter
ActivePrinter = "BullZip PDF Printer"
SetBullZipOutput FileName
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, Collate:=True, Background:=False, PrintToFile:= _
False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
ActivePrinter = OldPrinter
SetBullZipOutput ""
End Function

=========================

IMPORTANT!
If you plan to use the PDF document as soon you created it, be sure the print phase is over, example:

Sub MapiSendMail(FileName As String)
Dim OA As Outlook.Application
Dim objMsg As MailItem
Dim OBJSESSION As Object
Dim colCDORecips As Object
Dim colRecips As Object
Dim objCDORecip As Object
Dim objRecip As Object


Const cdoE_USER_CANCEL = &H80040113


Set OA = CreateObject("Outlook.Application", "localhost")
Set objMsg = OA.CreateItem(olMailItem)
objMsg.To = ""
objMsg.Subject = ""
Do While Dir(FileName) = "" 'this is the name of your PDF
'Give time to PDF printer to complete the job
Loop
objMsg.Attachments.Add FileName

objMsg.Display

Set objMsg = Nothing
Set OA = Nothing

End Sub

=========================

Hope this help.

Ciao

Posted: Fri Feb 29, 2008 11:25 am
by cwany
well, here goes my code (some parts are omitted to make it more readable)

[code]Private Sub PrzyciskEksport_Click()

[...]

Dim PDFPrinter As New Bullzip.PDFPrinterSettings

[...]

PDFPrinter.SetValue "Output", [some variable goes here]
PDFPrinter.SetValue "ShowPDF", "no"
PDFPrinter.SetValue "ConfirmOverwrite", "no"
PDFPrinter.SetValue("ShowSaveAS", "nofile")
PDFPrinter.WriteSettings

[...]

End Sub[/code]

somehow I can't get through "SaveAs" dialog
i'm reading and reading this post, but i can't find, what i'm doing wrong...
any help?