WriteSettings (String) - Class doesn't support Automation

About the programming interface for the virtual PDF printer driver.

Moderator: jr

Post Reply
richardck
Posts: 2
Joined: Wed Mar 18, 2015 3:51 pm

WriteSettings (String) - Class doesn't support Automation

Post by richardck »

I'm trying to write different runonce.ini files so that I can get simultaneous users of Pdf Printer to work.
And I'm doing this from vbs.
I'm trying to do it by using WriteSettings to write a runonce_DOCUMENTNAME.ini file.

While the standard form of PdfSettings.WriteSettings (ie with a boolean parameter - True for runonce) works, the variant with a string parameter doesn't even run.

settings.WriteSettings( settingsfilename )

Gives:
Microsoft VBScript runtime error: Class doesn't support Automation: 'WriteSettings'

Can anyone advise what I might be doing wrong.
I've just included the basic calls above - I can provide a bit more if it would be helpful.

Regards,
Richard.
jr
Site Admin
Posts: 500
Joined: Sun Mar 26, 2006 12:28 pm

Re: WriteSettings (String) - Class doesn't support Automatio

Post by jr »

Hi,

If you want to write a specific runonce file then you should use the WriteSettingsFile and not the WriteSettings method.

Before you can call WriteSettingsFile, you need the correct file name that will match the job name in your printer job queue.

You can get the full path of the settings file using ComPdfSettings.GetSettingsFilePathEx2.

http://www.biopdf.com/guide/dotnet/chm/ ... 570541.htm

Here is some sample code that uses that technique. This is just a random example. It may also contain stuff you don't need.

Option Explicit

Dim fso, currentdir

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

TestSpecificRunonce currentdir

sub TestSpecificRunonce(currentdir)
dim objSettings, objUtil
dim fn, jobname, cmd
dim printername, statusfile
dim WshShell, ret, output

Rem -- Create the COM object to control the printer.
set objSettings = CreateObject("Bullzip.PDFSettings")
set objUtil = CreateObject("Bullzip.PDFUtil")

printername = objUtil.DefaultPrinterName

wscript.echo "Test Specific Runonce"
jobname = "Unit Test Job"
output = currentdir & "\out\Test specific runonce.pdf"
statusfile = currentdir & "\out\status.ini"

Rem -- Remove output files if they already exist
if fso.FileExists(statusfile) then fso.DeleteFile statusfile
if fso.FileExists(output) then fso.DeleteFile output

fn = objSettings.GetSettingsFilePathEx2("runonce", jobname)
wscript.echo "Job name is " & jobname
wscript.echo "File path is " & fn
wscript.echo "Output is " & output
objSettings.SetValue "output", output
objSettings.SetValue "statusfile", statusfile
objSettings.SetValue "ShowSettings", "never"
objSettings.SetValue "ShowPDF", "no"
objSettings.SetValue "WatermarkText", now
objSettings.SetValue "ShowProgress", "no"
objSettings.SetValue "ShowProgressFinished", "no"
objSettings.SetValue "SuppressErrors", "yes"
objSettings.SetValue "ConfirmOverwrite", "no"
objSettings.WriteSettingsFile fn

Rem -- Create a print job with the right name
cmd = """" & currentdir & "\rawprint.exe"" """ & jobname & """ """ & printername & """ """ & currentdir & "\in\test_windows8.ps"""
wscript.echo "Run " & cmd

Set WshShell = WScript.CreateObject("WScript.Shell")
ret = WshShell.Run(cmd, 1, true)

Rem -- Wait until the status file is created.
WScript.Echo "Wait for status file"
While fso.fileexists(statusfile)
Rem -- Wait for some milliseconds before testing again
wscript.sleep 100
Wend
end sub
richardck
Posts: 2
Joined: Wed Mar 18, 2015 3:51 pm

Re: WriteSettings (String) - Class doesn't support Automatio

Post by richardck »

Ok.

I was looking at the docs for PdfSettings, which don't mention WriteSettingsFile (or GetSettingsFilePathEx2), which are both in ComPdfSettings.
On trying it I find it works - well at least it doesn't cause an error.
I'll take a look at the rest of your example to get the rest right.

Why should I be using ComPdfSettings, rather than PdfSettings ?
(apart from that it works)
The example I started with ("COM Automation from Visual Basic Scripting") gets the settings object using the name "Bullzip.PdfSettings" so I didn't think to look for docs on ComPdfSettings. I don't program at all with COM usually so I don't really know its rules.
So does it not support overloading at all then ? That would make sense why I can't use an overloading version and need to use one with an explicit type.

Regards,
Richard.
jr
Site Admin
Posts: 500
Joined: Sun Mar 26, 2006 12:28 pm

Re: WriteSettings (String) - Class doesn't support Automatio

Post by jr »

The PdfSettings interface is more or less a COM edition of the equivalent .NET assembly. The ComPdfSettings is a modified interface that handles some of the problems you run in to in the COM world. One of these things is the fact that you cannot overload the functions. Extra functions were added to help in scripting languages such as VB Script where you don't have much control over types.

/Jacob
Post Reply