Visual Studio Development Bookmark and Share   
 index > Visual Basic Express Edition > Word in a service issue
 

Word in a service issue

I'm using a servic to periodically check a directory and Print to PDF any Word docs that get put there. This all worked fine on server 2003 with word xp. Now I'm using Server 2008 and Word 2007 and keep getting the same error. It works fine as an app, but fails as a service with: "This command is not available because no document is open"
Code below.
 
Imports Word = Microsoft.Office.Interop.Word
____________

Dim

wa = New Word.Application
Dim wd As Word.Document = wa.Documents.Open("c:\test.doc", False, True, False)
If Not wd Is Nothing Then wd.Activate()
wa.ActivePrinter =
"CutePDF Writer"
wa.ActiveDocument.PrintOut(False)
wd.Close(
False)
Mike Pietrorazio  Tuesday, October 13, 2009 2:58 PM
I would check out the following article. Office applications were never designed to run from unattended processes.

Considerations for server-side Automation of Office


Paul ~~~~ Microsoft MVP (Visual Basic)
Paul P Clement IV  Wednesday, October 14, 2009 2:09 PM
Mike

can't help you directly

but there is also a Visual Studio Tools for Office (VSTO) Forum that might be a good place to post your question


http://social.msdn.microsoft.com/Forums/en-US/vsto/threads
jwavila  Tuesday, October 13, 2009 7:02 PM
I would check out the following article. Office applications were never designed to run from unattended processes.

Considerations for server-side Automation of Office


Paul ~~~~ Microsoft MVP (Visual Basic)
Paul P Clement IV  Wednesday, October 14, 2009 2:09 PM
I was afraid of that. Since it worked fine in Server 2003, I had hoped it would also in 2008. I wonder why the interop class exists if you shouldn't use it?
Mike Pietrorazio  Wednesday, October 14, 2009 3:55 PM
Office automation is fine with apps that have a user interface but apps that don't provide one can't give feedback to the user in case of an error. Of course the main issue is the threading model limitation.
Paul ~~~~ Microsoft MVP (Visual Basic)
Paul P Clement IV  Wednesday, October 14, 2009 4:10 PM

You can use google to search for other answers

Custom Search

More Threads

• why have this error during installation?
• Optional sytem.diagnostics.Process.start parameters
• Installation software that installs sql express, my project and .net
• Books: Recommendations
• programmatically add new / update and delete from a datagridview
• System.InvalidOperationException in System.Windows.Forms.dll
• Splash screen problem
• IADs error.
• random link generator with auto send
• How do I play a .wav file from Resources?