locked
Word 2003 Interop.Word.dll on Server2008 not working without a human RRS feed

  • Question

  • Hi all, any help would be greatly appreciated!

    Background: A web site where users can upload a word doc. A scheduled task (that runs a console app) on the server then saves the doc as htm and txt version, then saves all three files into an sql db, then deletes the files from the file system.

    It does work when:

    • it's on Server2003 - no problem at all
    • on Server2008, a human is logged on to either run the console app, run the scheduled task, or watch the scheduled task run (triggered by the time)

    It doesn't work when:

    • the code is run from within the web app
    • the console app is invoked from within the web app
    • the scheduled task runs without anyone logged on to the server

    All of the file locations, application locations and scheduled task user is set up with the same user with full permissions. This is also the user that is logged on when it does work. The fact that it does work in certain circumstances, leads me to believe it's not a problem with permissions.

    Here is an excerpt from the code: 

    Dim sDOCRootTmp As String = "c:\wordapp\docs\"
    
    Dim wa As New Word.Application
    
    Dim sOriginalFileNameWithoutExtension As String = IO.Path.GetFileNameWithoutExtension(sOriginalFileName)
    
    Dim sTmpNameHTM As String = sOriginalFileNameWithoutExtension & ".htm"
    Dim sTmpNameTXT As String = sOriginalFileNameWithoutExtension & ".txt"
    
    Try
    	Dim wd As Word.Document = wa.Documents.Add(sDOCRootTmp & sOriginalFileName, False, Word.WdNewDocumentType.wdNewBlankDocument, False)
    
    	'SAVE THE HTM/TXT VERSIONS
    	wd.SaveAs(sDOCRootTmp & sTmpNameHTM, Word.WdSaveFormat.wdFormatFilteredHTML)
    	wd.SaveAs(sDOCRootTmp & sTmpNameTXT, Word.WdSaveFormat.wdFormatDOSTextLineBreaks)
    
    	'DISPOSE OF WORD OBJECTS
    	wd.Close(Word.WdSaveOptions.wdDoNotSaveChanges)
    	wd = Nothing
    
    Catch ex As Exception
    	Consol.WriteLine(ex.Message)
    	Consol.WriteLine("--------------------")
    	Consol.WriteLine(ex.StackTrace)
    End Try
    
    wa.Quit(Word.WdSaveOptions.wdDoNotSaveChanges)
    System.Runtime.InteropServices.Marshal.ReleaseComObject(wa)
    
    wa = Nothing
    

    The error message is always the same and on the same line:

    There is insufficient memory. Save the document now.
    --------------------
    at Word.Documents.Add(Object& Template, Object& NewTemplate, Object& DocumentType, Object& Visible) at wordapp.Module1.WordWork(String sOriginalFileName) in C:\wordapp\Module1.vb:line 71
    
    

    (why can an instance of the word application be created, but the documents collection cannot be modified??)

    Although, I have seen "The Windows Installer service could not be accessed" in the event viewer, but only when the the code above is NOT run as a scheduled task.

    Please, please help. This has been driving me crazy! It is working on much older, slower hardware and an older operating system - I'm trying to upgrade and this is the last obstacle to overcome.

    Thanks in advance for any help.

    Sunday, December 26, 2010 8:04 PM

Answers

  • Hi ,

    Office client applications (including Word) are not designed to be automated from server side. Article http://support.microsoft.com/kb/257757 says that server side automation of Office client applications is not recommended and not supported by Microsoft. This article also describes various issues which might arise if server side automation is used and it also talks about various alternatives to server side automation.

    Thanks,

    Pradip

     

    • Marked as answer by Jennifer Zhan Friday, December 31, 2010 5:55 AM
    Monday, December 27, 2010 8:07 PM

All replies

  • Hi ,

    Office client applications (including Word) are not designed to be automated from server side. Article http://support.microsoft.com/kb/257757 says that server side automation of Office client applications is not recommended and not supported by Microsoft. This article also describes various issues which might arise if server side automation is used and it also talks about various alternatives to server side automation.

    Thanks,

    Pradip

     

    • Marked as answer by Jennifer Zhan Friday, December 31, 2010 5:55 AM
    Monday, December 27, 2010 8:07 PM
  • Did you ever resolve this problem Pasilda?

    I am having a similar issue with server 2008, where a human has to be logged into the server for a Document Merge application to work.

    Please reply if you got this to work for you.

    Rob...

    Friday, July 8, 2011 1:39 PM