Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Word Doc Programmatically

Status
Not open for further replies.

thedman00

Programmer
Jun 11, 2003
46
AT
I'm attempting to create a word document programmatically on an asp.net page without using VS in VB.Net. I'm having a hard time finding the code to make a reference to the Microsoft Word library that is need.

Thanks in advance
 
Do you mean that you want to display the word doc in the page, or taht you want to do something with it in the background??

Rob
 
Sorry about taking a while to get back.. I was hoping you were asking for something else..

In html you could href to a word doc [red](<a href=myworddoc.doc>open doc</a>)[/red]and it would open in the browser, but I can't find out how to make the response object perform the same stunt.

:(

Rob
 
I know from asp.net you can create a word doc with code similar to the following:

Dim wrdDoc As Word.Application
Set wrdDoc = New Word.Application

But not only am I unsure of the exact syntax but I also know that you have to make a reference to the Microsoft Word Object lib.

If anyone knows the proper code or how to refer to the lib let me know
 
Problem with the dim approach is that it would create it on the web server not in the client..

Unless you could open it into the response stream....

hmmmmm

Worth a try..

Rob
 
Any luck here with Word Docs? I'm looking to do the same type of thing...

dlc
 
If you can create the word document on the server and save it to a temp location, you can then send it to the client through the Response.OutputStream. Just set the Response.ContentType = &quot;application/msword&quot;.

Example:

ASPX File:
Code:
<%@ Page language=&quot;c#&quot; Codebehind=&quot;getDoc.aspx.cs&quot; AutoEventWireup=&quot;false&quot; Inherits=&quot;bulletins.getDoc&quot; %>

getDoc.aspx.cs Page_Load event:
Code:
Response.ContentType = &quot;application/msword&quot;;
Response.WriteFile( @&quot;D:\Stuff\temp.doc&quot; );

In IE, the document will probably open in their browser. In other browsers, it will prompt them to download the document, presumably as getDoc.aspx.doc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top