Word.Application VS Process.Start(ProcessStart)

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
WFM
Posts: 21
Joined: Thu Jun 02 2005

Word.Application VS Process.Start(ProcessStart)

Post by WFM »

I'm new so please bear with me a bit-- in a .NET application when printing MS Word documents is it preferred to load the Word library such as:
Dim objApp As Word.Application
Dim objDoc As Word.Document
objApp = CType(CreateObject("Word.Application"), Word.Application)
objApp.Visible = False
objApp.ActivePrinter = PDFPrinter
objDoc = objApp.Documents.Open(CType(sFile, Object))
objApp.PrintOut(False, False, 0, CType(sNew, Object), "", "", 0, 1, "", 0, True, False)
objApp.Quit()

or use the process code like:

Dim processHolder As New Process
Dim ProcessStart As New ProcessStartInfo(sFile)
For Each Verb In ProcessStart.Verbs
If Verb.ToLower() = "print" Then
CanPrint = True
ProcessStart.Verb = Verb
Exit For
End If
Next
If CanPrint Then
processHolder = Process.Start(ProcessStart)
End If

Thanks
Bill
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

It is better to use the first method i.e to load the Word library because this method will give you more flexibility and control over the process.

Hope this helps.
WFM
Posts: 21
Joined: Thu Jun 02 2005

Post by WFM »

Only problem is that the time difference is quite a bit-- to loop 30 files first method took 150 seconds the second only 53-- that a big difference especially when I plan to do thousands. Do you know of a way to speed up the first method?
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

In the loop you are not creating the Word object each time, right?

You are only looping through:

Code: Select all

objDoc = objApp.Documents.Open(CType(sFile, Object)) 
objApp.PrintOut(False, False, 0, CType(sNew, Object), "", "", 0, 1, "", 0, True, False)


From what I see you are setting background printing to False, this will speed printing.

I don't know of other ways to speed printing.
Post Reply