Dear bullzip team,
below http://www.biopdf.com/guide/examples/batch_printing/ I found vbs code for batch creation of .pdfs with bullzip. Based on my limited programing knowledge and some examples on the internet I tried to convert the code to vba to use it within an excel makro which I had programmed earlier. This is the result:
--------------------------
Sub PrintSheetAsPDFwithBullZip()
Dim fso As New FileSystemObject
Dim cff As New Bullzip.PDFPrinterSettings
Dim currentdir As String
currentdir = "C:\Bullzip\batch"
cff.SetPrinterName ("Bullzip PDF Printer")
Set fldr = fso.GetFolder(currentdir & "\in")
cnt = 0
For Each f In fldr.Files
With cff
cnt = cnt + 1
output = currentdir & "\out\" & Replace(f.Name, ".txt", "") & ".pdf"
Rem -- Set the values
.Init
.SetValue "Output", output
.SetValue "ShowSettings", "never"
.SetValue "ShowPDF", "no"
.SetValue "WatermarkText", Now
.SetValue "ShowProgress", "yes"
.SetValue "ShowProgressFinished", "no"
.SetValue "SuppressErrors", "no"
.SetValue "ConfirmOverwrite", "no"
Rem -- Write settings to the runonce-Invoice.ini
.WriteSettings True
End With
Rem -- Print the document
PrintFile = currentdir & "\in\" & f.Name
cmd = currentdir & "\printto.exe " & PrintFile & " " & Chr(34) & "Bullzip PDF Printer" & Chr(34)
Call VBA.Shell("C:\Windows\system32\cmd.exe /c " & cmd, 0)
Application.Wait (Now + TimeValue("0:00:01"))
Next
End Sub
--------------------------
As you can see I wasnt very successfull. It doesnt work either; Although it runs without crashing, nothing is beeing created within the "out" folder. It appears to me that the reasons for the problem are the quotation marks that are automatically beeing put in front and at the end of the "cmd" string: "C:\Bullzip\batch\printto.exe C:\Bullzip\batch\in\1.txt "Bullzip PDF Printer""
If I copy the code manualy in the command line without the quotation marks it seems to work: C:\Bullzip\batch\printto.exe C:\Bullzip\batch\in\1.txt "Bullzip PDF Printer".
Does someone have a solution to this?
Thanks in advance,
Andreas
Bullzip command line quotation marks
Moderator: jr
Re: Bullzip command line quotation marks
Hi,
Try replacing
cmd = currentdir & "\printto.exe " & PrintFile & " " & Chr(34) & "Bullzip PDF Printer" & Chr(34)
With
cmd = currentdir & "\printto.exe " & PrintFile & " ""Bullzip PDF Printer"""
In VB a quote is encoded as a double quote in a string.
Try replacing
cmd = currentdir & "\printto.exe " & PrintFile & " " & Chr(34) & "Bullzip PDF Printer" & Chr(34)
With
cmd = currentdir & "\printto.exe " & PrintFile & " ""Bullzip PDF Printer"""
In VB a quote is encoded as a double quote in a string.
Re: Bullzip command line quotation marks
Yes! now it works! Thank you so much!
Best regards,
Andreas
Best regards,
Andreas
Re: Bullzip command line quotation marks
Dear admin,
I implemented the makro and I works great except one thing. The xls and xlsx files are not beeing converted to .pdf format without the settings dialog appearing. It must have something to do with a .xls workbook beeing active during the process and therefore the runonce.ini not being created or deleted properly. The makro runs through all .xls or .xlsx files contained in the source folder but then somehow it finds only one runonce.ini; so it requests the missing information for the conversion of the other .xls and .xlsx files through the settings dialog.
Another interesting thing is, that when I copy this code below the call comand to make sure that it only continues with the next file when the .xls or .xlsx has been converted to .pdf and the runonce.ini is gone, it runs forever. It only stops when I delete the runonce.ini manually.
----------------------------
Do While Dir$("C:\Users\John\AppData\Local\PDF Writer\Bullzip PDF Printer\runonce.ini", vbNormal) = "runonce.ini"
MsgBox ("still there")
Loop
---------------------------
Then, after! I deleted the runonce.ini the conversion starts, and then, of course the settings dialog appears. Why does the conversion only start AFTER above process has been finished. The same happens if I use Application.Wait (Now + TimeValue("0:00:01")) instead. There the conversion also starts AFTER the break.
That doesnt make any sense to me. My guess is that it must have something to do with what is beeing active at the time the makro runs.
Do you have any ideas?
Thank you,
Andreas
I implemented the makro and I works great except one thing. The xls and xlsx files are not beeing converted to .pdf format without the settings dialog appearing. It must have something to do with a .xls workbook beeing active during the process and therefore the runonce.ini not being created or deleted properly. The makro runs through all .xls or .xlsx files contained in the source folder but then somehow it finds only one runonce.ini; so it requests the missing information for the conversion of the other .xls and .xlsx files through the settings dialog.
Another interesting thing is, that when I copy this code below the call comand to make sure that it only continues with the next file when the .xls or .xlsx has been converted to .pdf and the runonce.ini is gone, it runs forever. It only stops when I delete the runonce.ini manually.
----------------------------
Do While Dir$("C:\Users\John\AppData\Local\PDF Writer\Bullzip PDF Printer\runonce.ini", vbNormal) = "runonce.ini"
MsgBox ("still there")
Loop
---------------------------
Then, after! I deleted the runonce.ini the conversion starts, and then, of course the settings dialog appears. Why does the conversion only start AFTER above process has been finished. The same happens if I use Application.Wait (Now + TimeValue("0:00:01")) instead. There the conversion also starts AFTER the break.
That doesnt make any sense to me. My guess is that it must have something to do with what is beeing active at the time the makro runs.
Do you have any ideas?
Thank you,
Andreas
-
- Posts: 1
- Joined: Thu Nov 22, 2012 8:57 pm
- Location: Наша Родина
- Contact:
Bullzip command line quotation marks
i am using this cmd bat file to create a folder for users and give a permissions on it.
Set_permissions.bat :
SET variable
SET variable=string
SET /A variable=expression
SET variable=
SET /P variable=promptString
SET "
MD "D:User_Foldersvariable"
CACLS D:User_Foldersvariable /E /T /C /G "variable":F
Call Set_permissions.bat
Variable is user name,
Problem i have,it only gives me to create 1 user same time.
so every time i have to manually enter new user names,
If anyone knows if i can create a txt file with user names and this bat can read them them from it?
And pass all to variable line one after another.
Thank you very much.
Set_permissions.bat :
SET variable
SET variable=string
SET /A variable=expression
SET variable=
SET /P variable=promptString
SET "
MD "D:User_Foldersvariable"
CACLS D:User_Foldersvariable /E /T /C /G "variable":F
Call Set_permissions.bat
Variable is user name,
Problem i have,it only gives me to create 1 user same time.
so every time i have to manually enter new user names,
If anyone knows if i can create a txt file with user names and this bat can read them them from it?
And pass all to variable line one after another.
Thank you very much.
Re: Bullzip command line quotation marks
Hoping to piggyback onto this thread. I've used the code with your change. My code is now:
Sub PrintEmailwithBullzip(ByVal strPutInFolder, ByVal Filename As String)
Dim fso As New FileSystemObject
Dim cff As New Bullzip.PDFPrinterSettings
'cff.SetPrinterName ("Bullzip PDF Printer")
'Set fldr = fso.GetFolder(currentdir & "\in")
'cnt = 0
'For Each F In fldr.Files
With cff
output = strPutInFolder & Filename & ".pdf"
Rem -- Set the values
.Init
.SetValue "Output", output
.SetValue "ShowSettings", "never"
.SetValue "ShowPDF", "no"
.SetValue "WatermarkText", Now
.SetValue "ShowProgress", "yes"
.SetValue "ShowProgressFinished", "no"
.SetValue "SuppressErrors", "no"
.SetValue "ConfirmOverwrite", "no"
Rem -- Write settings to the runonce-Invoice.ini
.WriteSettings True
End With
Rem -- Print the document
PrintFile = strPutInFolder & Filename & ".pdf"
cmd = "C:\Media\Bullzip\printto.exe " & PrintFile & " ""Bullzip PDF Printer"""
'Call Shell("C:\Windows\system32\cmd.exe /c " & cmd, 0)
'Shell("C:\Windows\system32\cmd.exe" /c & cmd, 0)
'Call Shell(cmd, 0)
Application.Wait (Now + TimeValue("0:00:01"))
End Sub
I believe I've passed the strPutInFolder & Filename parameters correctly. (I'm a copy/paste VBA amateur).
You can see the three variations I've tried to get Bullzip to create the PDF. Nothing seems to happen. Where am I going wrong.
Sub PrintEmailwithBullzip(ByVal strPutInFolder, ByVal Filename As String)
Dim fso As New FileSystemObject
Dim cff As New Bullzip.PDFPrinterSettings
'cff.SetPrinterName ("Bullzip PDF Printer")
'Set fldr = fso.GetFolder(currentdir & "\in")
'cnt = 0
'For Each F In fldr.Files
With cff
output = strPutInFolder & Filename & ".pdf"
Rem -- Set the values
.Init
.SetValue "Output", output
.SetValue "ShowSettings", "never"
.SetValue "ShowPDF", "no"
.SetValue "WatermarkText", Now
.SetValue "ShowProgress", "yes"
.SetValue "ShowProgressFinished", "no"
.SetValue "SuppressErrors", "no"
.SetValue "ConfirmOverwrite", "no"
Rem -- Write settings to the runonce-Invoice.ini
.WriteSettings True
End With
Rem -- Print the document
PrintFile = strPutInFolder & Filename & ".pdf"
cmd = "C:\Media\Bullzip\printto.exe " & PrintFile & " ""Bullzip PDF Printer"""
'Call Shell("C:\Windows\system32\cmd.exe /c " & cmd, 0)
'Shell("C:\Windows\system32\cmd.exe" /c & cmd, 0)
'Call Shell(cmd, 0)
Application.Wait (Now + TimeValue("0:00:01"))
End Sub
I believe I've passed the strPutInFolder & Filename parameters correctly. (I'm a copy/paste VBA amateur).
You can see the three variations I've tried to get Bullzip to create the PDF. Nothing seems to happen. Where am I going wrong.