Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Word Document with ASP.NET

0 views
Skip to first unread message

ayc...@gmail.com

unread,
Jun 7, 2006, 5:37:35 PM6/7/06
to
Hi all,

I have a scenario where users fills in textbox fields on ASP.NET page
from the server and when he/she clicks on a download button, the data
from fields will insert into an existing word template.

The user will then be asked whether to save as or open the word
document on his client machine.

Question1)Is there a way to manipulate the word document in memory
without having to save it onto server's disk?
Currently, I am using the Word class from Microsoft Word 11.0 object
library to open existing word template, insert data into bookmark
location, and save as new document on the server. Then I open the file
and send the file for user to download through Response.WriteFile().
This method works, but it requires a physical document to be created
everytime.

Question2)How do I check the file lock to see if other process is
finished with the file and my application can go ahead and write to it
(in C#)? If there's some sample code for checking that, it will be
great!

Thanks abunch!

Anthony

Cowboy (Gregory A. Beamer)

unread,
Jun 7, 2006, 8:25:59 PM6/7/06
to
1) There are third party libraries to do this (Office Writer is a good shot)
2) Better option is to either a) create the doc in memory from a string (ie,
put the word doc into a string) or b) clone off the in-memory representation
so the file can be released. This is also easier when you DON'T use the
office DLLs.

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
<ayc...@gmail.com> wrote in message
news:1149716255.3...@i40g2000cwc.googlegroups.com...

Steve C. Orr [MVP, MCSD]

unread,
Jun 8, 2006, 8:41:45 PM6/8/06
to
Server side COM automation with Office (like you're doing) is not
recommended:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2

Here are some tips and suggestions for working with Word (and Excel) the
right way:
http://SteveOrr.net/articles/ExcelExport.aspx
http://SteveOrr.net/articles/ExportPanel.aspx
http://SteveOrr.net/reviews/AsposeWord.aspx
http://SteveOrr.net/reviews/OfficeWriter.aspx
http://msdn.microsoft.com/office/understanding/vsto/

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


<ayc...@gmail.com> wrote in message
news:1149716255.3...@i40g2000cwc.googlegroups.com...

0 new messages