locked
Reading / writing word documents RRS feed

  • Question

  • User-250092123 posted

     I need to write a web application that will read Microsoft Word documents stored on the server. Those documents will have some tags on them, and some will be substituted by values on tables in the database, and those wich are not associated with values on the database will be presented in a web form for the user to enter values for them.

    I did a lot of research on the internet and it seems that the only way to deal with word documents is through COM ( you use Microsoft.Office.Interop.Word, then you record macros in Word and kind of translate them to c# using those classes). I Even wrote a class using this method and tested using Windows Forms. Everything seems to be working fine, but when i use it with ASP.Net it doesn't work ok, it doesn't copy from server clipboard (i used System.Windows.Forms.IDataObject data = Clipboard.GetDataObject();).

    Besides that, there are a lot of issues about this approach, i'd like to know if anyone ever dealed with similar stuff... First: There is no direct way to retrieve data from the document, wright? You have to use server clipboard. Even if it was working, in a multi user environment it would cause a lot of trouble... Second: Using Windows Forms i could notice that whenever i open a document, it gets blocked. If i try to open it while it's being used by another instance of the program it shows a window to confirm if i want to open a read-only version of it, and the method gets waiting... 

    Please, i really need help with those stuff, any help is welcome.

     

    Wednesday, March 25, 2009 4:01 PM

All replies

  • User-250092123 posted

    bcanonica, that's exactly what i told that i had already done...

    Now, i found a way to read from the server clipboard in ASP.net if anyone is interested, you have to use another thread, check out this article:

    http://www.telerik.com/community/forums/community-forums/interesting-resources/using-clipboard-class-in-asp-net.aspx

    Also, another hint: if you'll make something like replacing tags, you should use "replace all" for replacing each tag, otherwise some tags won't be replaced, don't know why...

     But what about the other problems, anyone? Has no one worked with Word in ASP.net before?

    Thursday, March 26, 2009 8:19 AM