Problem if Word is open

About the programming interface for the virtual PDF printer driver.

Moderator: jr

Problem if Word is open

Postby patapatty » Wed Nov 16, 2011 10:44 am

Hi. I use this code
Dim fso As FileSystemObject, currentDir As String
Dim obj As Bullzip.PDFPrinterSettings, PrinterName As String, runonce As String, fldr As Folder, cnt As Integer, f As File
Dim output As String, PrintFile As String
Dim p As New ComPdfUtil

Set fso = CreateObject("Scripting.FileSystemObject")
Set obj = CreateObject("BullZip.PDFPrinterSettings")
PrinterName = obj.GetPrinterName
runonce = obj.GetSettingsFileName(True)
currentDir = "C:\Documents and Settings\Prova\Desktop\Esempi"
Set fldr = fso.GetFolder(currentDir & "\in")
cnt = 0
For Each f In fldr.Files
cnt = cnt + 1
output = currentDir & "\out\" & cnt & ".pdf"
If UCase(Right(f.Name, 3)) = "PDF" Then
f.Copy output
Call obj.SetValue("Output", output)
Call obj.SetValue("ConfirmOverwrite", "No")
Call obj.SetValue("ShowSaveAS", "Never")
Call obj.SetValue("ShowSettings", "Never")
Call obj.SetValue("ShowPDF", "No")
Call obj.SetValue("OpenFolder", "No")
Call obj.SetValue("ShowProgress", "No")
Call obj.SetValue("ShowProgressFinished", "No")
Call obj.SetValue("DisableOptionDialog", "Yes")
Call obj.SetValue("SuppressErrors", "Yes")
Call obj.SetValue("Format", "PDF")
Call obj.SetValue("AppendIfExists", "No")

obj.WriteSettings True

PrintFile = currentDir & "\in\" & f.Name
p.PrintFile PrintFile, PrinterName
While fso.FileExists(runonce)
Sleep (100)
End If
Set obj = Nothing
Set p = Nothing
The problem is that if Word is open and one of the file to be printed is .doc, there is the error "No process is associated with this object"
What can I do?


Posts: 3
Joined: Tue Nov 15, 2011 11:19 am

Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest