ERROR "Printer Name Property"

Installation and setup related issues.

Moderator: jr

chris283
Posts: 1
Joined: Thu Oct 25, 2012 12:42 pm

ERROR "Printer Name Property"

Post by chris283 »

I have set up VBs scripts so that i can access the printer, but i have run into some problems, as i have been stuck on the same error all week, the error is "The PrinterName property must be set before calling the GetSettingsFilePath", i dont really under stand this error as my code shows i have already defined the name of the printer way before it get to line 80 of the script, any help on this issue would be of great help, i will paste and example of my vbs code, and hopefully someone spots and error i can see, thanks in advance

Rem -- Get current path of this script.
Set fso = CreateObject("Scripting.FileSystemObject")
currentdir = fso.GetAbsolutePathName(".")

Rem -- Read the info xml
Set xmldom = CreateObject("MSXML.DOMDocument")
xmldom.Load("C:\Montupet\PDF" & "\info.xml")

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

Rem -- Create the COM object to control the printer.
set objs = CreateObject("bullzip.PdfUtil")
set objs = CreateObject("bullzip.PDFSettings")
Rem -- Get the default printer name.
Rem -- You can override this setting to specify a specific printer.
printername = "PDF Writer - bullzip"
objs.printername = printername
runonce = objs.GetSettingsFilePath (true)
set oArgs = wscript.Arguments

Rem -- Print all the files in the 'in' folder
wscript.echo "HELLO"
wscript.echo "HELLO"
wscript.echo "HELLO"
wscript.echo "HELLO"
wscript.echo "HELLO"
dim file_name, template
dim command_line_args

set command_line_args = wscript.Arguments

'Check if any Arguments have been passed to our script.
if command_line_args.count > 0 then
file_name = command_line_args(0)
template = command_line_args(1)

Set oWd = CreateObject("Word.Application")
oWd.Visible = False
wordname = """" & "C:\MTMS\MTMSPRT\" & file_name & """"
wscript.echo wordname
Set oDoc = oWd.Documents.Open(wordname)
Set oPS = oDoc.PageSetup

' Reduce the margins to .5" (36 points)
oPS.LeftMargin = 8.4
oPS.RightMargin = 0.2

'Save changes to doc on closing and quit Word
oDoc.Saveas wordname , 0
wscript.echo "Saved"
oDoc.Close
wscript.echo "close"
oWd.Quit
wscript.echo "Quit"
Set oWd = Nothing
Set objShell = Nothing

wscript.echo "Cleared Word"
Set oWd = Nothing
Set objShell = Nothing


output = "C:\MTMS\MTMSPRT\PDFs\" & Replace(ucase(file_name), "DOC", "") & "PDF"

Rem -- Set the values
objs.Init
objs.SetValue "Output", output
objs.SetValue "ShowSettings", "never"
objs.SetValue "ShowPDF", "no"
objs.SetValue "ShowProgress", "no"
objs.SetValue "ShowProgressFinished", "no"
objs.SetValue "SuppressErrors", "no"
objs.SetValue "ConfirmOverwrite", "no"
objs.SetValue "superimpose", template

Rem -- Write settings to the runonce-Invoice.ini

objs.WriteSettings True // Error on this line!!!!!
wscript.echo "runonce created"
Rem -- Print the document
printfile = "c:\MTMS\MTMSPRT\" & file_name
cmd = """" & "c:\Montupet\PDF\printto.exe"" """ & printfile & """ """ & printername & """"
wscript.echo "printfile line setup"
Set WshShell = WScript.CreateObject("WScript.Shell")
ret = WshShell.Run(cmd, 1, true)
wscript.echo "shell run start"
Rem -- Wait until the runonce is removed.
Rem -- When the runonce is removed it means that the gui.exe program
rem -- has picked up the print job and is ready for the next.
While fso.fileexists(runonce)
wscript.echo "checking for runonce"
Rem -- Wait for some milliseconds before testing again
wscript.sleep 100
Wend

wscript.echo "runonce gone"
end if

Rem -- Dispose the printer control object
set objs = Nothing
jr
Site Admin
Posts: 500
Joined: Sun Mar 26, 2006 12:28 pm

Re: ERROR "Printer Name Property"

Post by jr »

Hi,

I tried some of your code and it works for me if I change the printer name to something valid on my system.

Here are some suggestions:

1. Make sure your have the latest version of the PDF Printer installed.
2. Try to isolate the problem with a simple script such as the one below:

Set objs = CreateObject("bullzip.PDFSettings")
objs.printername = "Bullzip PDF Printer"
runonce = objs.GetSettingsFilePath(True)
wscript.echo runonce

Let me know if that works :-)

Regards,
Jacob
Post Reply