Page 1 of 1

Problem if Word is open

Posted: Wed Nov 16, 2011 10:44 am
by patapatty
Hi. I use this code
[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
Else
obj.Init
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)
Wend
End If
Next
Set obj = Nothing
Set p = Nothing
[/code]
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?

Thank's

Patrizia