473,326 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Word Document with ASP.NET

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

Jun 7 '06 #1
2 2497
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!
*************************************************
<ay****@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
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

Jun 8 '06 #2
Server side COM automation with Office (like you're doing) is not
recommended:
http://support.microsoft.com/default...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
<ay****@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
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

Jun 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Microsoft | last post by:
I'm trying to display a word document inside a web page, but everytime I do I get this error: Error Type: Microsoft VBScript runtime (0x800A0046) Permission denied: 'CreateObject' Does...
4
by: Otis Hunter | last post by:
I have been given an Access Database which contains a table that has an OLE object field that contains a Word document. That table contains hundreds of records. I would like to find out how I can...
7
by: Dave | last post by:
Apologies for the newbie question. I have created a vb.net program for my company that is designed to work with Word Templates (about forty of them that we commonly use) that are selected by the...
3
by: Adam Faulkner via DotNetMonster.com | last post by:
I want to create a method within a class that opens a Microsoft Word 2000 Document and has the facility to Create a new word document and then extract a Page that exists within the original Word...
1
by: Adam Faulkner via DotNetMonster.com | last post by:
I had a problem before extracting pages from an existing word document and then inserting the content into a new word document. The following code below works with Microsoft Word 2000 Function...
3
by: Niyazi | last post by:
Hi, Its like a I am searching alot but still not found or satisfy what I found it. My question is that I had SQL server that contains some data. I also have a application folder call...
2
by: Colin Halliday | last post by:
I have a Word 2003 mail merge main document (form letter) that is linked to another Word document data source for the mail merge. If I open this doc using the Word GUI, it first asks me to...
0
by: Niyazi | last post by:
Hi, I created application that store the data in SQL SERVER that reside on network. The client also use this application to access the resources provided with application. But is the client want...
0
southoz
by: southoz | last post by:
Good ay all , I'm fairly new to access(a little over 5 weeks now). Since I'v started I have picked up a lot of useful information from forums such as this and in doing so will share that information...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.