Can the server document do the following (Microsoft Word VSTO 2005):

Hi

There is a web application that is currently producing large complex reports, many pages long, and the reports include labels, and values behind the labels; there are no charts.

We are planning to use Microsoft Word 2003 and or 2007 when finalized and stable for the report viewing part.

The reports today are done HTML, there are tons of technologies that we can use for reporting, but at the end, the most usable tool when it comes to printing is Microsoft Word.

The data is entered using Microsoft InfoPath, ASPX pages, Microsoft Word itself (for rich formatted contents), as well as data coming from other systems.

The application is web based; the end user will be using internet explorer to open the reports.

Can I do the following using VSTO on the server side, I know I can do a lot on the client side, and there will be a lot of code there, but this is what I want on the server:

Can I use the server document to open a word document that already have C# code inside, load an xml document, and bind them together and execute the C# code


Can I then use the server document to merge multiple word documents on the server side, and send them to the end user as one word document

The idea behind that is to let multiple developers to work on multiple parts of the report at the same time, you cannot lock a large report to a single developer, it will be easy to split it to small parts and then merge it together at run time.


Can I insert html contents to the word document at the server side, as you know, converting a large report is not easy and takes time, we are planning to convert part of it, then inject whatever is not converted yet and still as html to the word ml report.

Thanks for your help, I have lots of questions, but let’s start with these.



Answer this question

Can the server document do the following (Microsoft Word VSTO 2005):

  • CarolChi

    I'll try to answer each part in turn:

    1) "Can I use the server document to open a word document that already have C# code inside, load an xml document, and bind them together and execute the C# code "

    Not directly. ServerDocument is provided to allow the developer to manipulate a document's manifests (application manifest and cached data manifest) and cached data on the server in a lightweight manner. It does not load or execute any of the code associated with the document. The customization assembly and its contained code is only loaded and executed when the document is loaded and run by VSTO within the host application (e.g. Word or Excel). It is essentially meaningless (though not impossible) to run the customization's code outside the context of the host application as none of the Office objects referenced in the code will be instantiated and no events will fire.

    2) "Can I then use the server document to merge multiple word documents on the server side, and send them to the end user as one word document "

    No. ServerDocument does not allow the developer to manipulate the document contents of the Word file in question - only the document's manifests and cached data which are maintained entirely separately from the document data, though they do all reside within the same physical file.

    3) "Can I insert html contents to the word document at the server side, as you know, converting a large report is not easy and takes time, we are planning to convert part of it, then inject whatever is not converted yet and still as html to the word ml report."

    Again, ServerDocument does not allow direct manipulation of the document's contents.

    It sounds to me as if what you need to do is to maintain the separate parts of the document as XML or HTML while multiple people are editing them and then to import all the parts into a new Word document at the end. ServerDocument is designed only to access the parts of the file that are relevant to VSTO runtime execution of the document and does not provide a wrapper around the Word object model. Much of the tasks you described could be achieved via automation of Word through the Office PIAs. This, however, would require Word to be installed and automated on the server which would likely load the server too much.

    In summary, ServerDocument is designed to be as lightweight as possible and thus adapted specifically for server use - it does not expose any of Word or Excel's object model. It is not envisaged that Word or Excel would ever be installed on to a production server. It is possible that future versions of Office and/or ServerDocument will provide a limited subset of the Office object models to allow some high-level manipulation of documents on the server in the way you mention, but this is not supported now.

    Let me know if you have any other questions.

    Best regards, Richard.


  • -Roel-

    Thank you very much for the response, I think I need to read more about the server document, I still don’t understand what does the Word Manifest does.

    I am still in the demo stage, if the server side code cannot be done at this moment, I can use the client side too, all the users already have word 2003 installed.

    Ok, so here is another scenario:

    1- I will create a new word document with C# code behind.

    2- This Word document will connect using the web services to the system and will extract the needed data.

    3- And will display the data in separate bookmarks on the document.

    Until this point I don’t think I will have any problems, I was doing tests with bookmarks today, and they seem to do the job (at least for now).

    Now, the question is how can I send the document to the client using IIS, I am looking for a scenario where I have the document and the DLL file published on the IIS, and then the user will simply open the document from IIS, the dll will run, and the document will extract and display the data.


  • RohitMehta802003

    Hi G.T.

    (SD) ServerDocument won't let you run any code on server side. With SD you can extract or inject data that have been previously cached on client side into the document.

    However there is also a workaround that can help you to solve at least a part of the scenario. You can create a word document based on WOML format (verbose word xml..) and been able to add/remove any section of the document using System.XML namespaces. If you customize the document you'll be also able to manage any public cached data.

    Keep in mind that:

    With serverdocument you don't have the control of the whole content document, you can make any change at manifest and cached data level.

    ServerDocument does not fully support shadow copies (multiple writers and multiple readings).

    The implemented access mode is: multiple readers and only 1 writer at time. (see: Office notification when a document is locked by someone else)

    hopes this helps,



  • Can the server document do the following (Microsoft Word VSTO 2005):