473,405 Members | 2,373 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,405 software developers and data experts.

Sending data to Word

I have an ASP.Net 2.0 intranet application and would like to be able to send
a name and address to an msword content type or something. I want to first
just send out the person's name and address to the upper-left portion of the
newly created .doc format so the user can finish the letter and save/print
the letter. I have done some exporting to Excel from a GridView but I'm not
sure how to create in Word.

All users have Microsoft Word and IE6+. Thanks.

David
Apr 23 '07 #1
3 1357
"David C" <dl*****@lifetimeinc.comwrote in message
news:ua**************@TK2MSFTNGP05.phx.gbl...
>I have an ASP.Net 2.0 intranet application and would like to be able to
send a name and address to an msword content type or something. I want to
first just send out the person's name and address to the upper-left portion
of the newly created .doc format so the user can finish the letter and
save/print the letter. I have done some exporting to Excel from a GridView
but I'm not sure how to create in Word.

All users have Microsoft Word and IE6+. Thanks.
Firstly, under no circumstances attempt to do Office automation in ASP.NET -
it's not supported by Microsoft because it's just not designed to work in
this environment:
http://support.microsoft.com/default...US;q257757#kb2

Luckily, your requirements do not require automation, and are extremely
simple.

Basically, just create an HTML document and then save it with a .doc
extension.

As an example, open Notepad, paste the text below, and then save it as
Bill.doc

<html>

<body>
Bill Gates<br />
Microsoft Corporation<br />
Redmond<br />
<br />
Dear Bill,<br />
<br />
</body>

</html>
Now double-click the newly created "Word" document - Word will treat it just
like a native Word document.
Apr 23 '07 #2
Mark,
I'm not sure if I was clear with my request. I want to do something similar
to below from the web page to have it create a Word document (instead of
Excel like the example). Thanks.

Response.Clear()

Response.ContentType = "application/vnd.excel"

Response.Charset = ""

Response.AddHeader("content-disposition", "attachment;filename=search.xls")
Dim gv As New GridView

Dim strSQL As String

Dim conFileData As SqlConnection

Dim cmdSel As SqlCommand

conFileData = New
SqlConnection(ConfigurationManager.ConnectionStrin gs("FiledataConnectionString").ConnectionString)

conFileData.Open()

strSQL = txtExcelSQL.Text
'Get records based on sql

cmdSel = New SqlCommand(strSQL, conFileData)

Dim dtr As SqlDataReader

dtr = cmdSel.ExecuteReader()

gv.DataSource = dtr

gv.DataBind()

dtr.Close()

conFileData.Close()
Dim sw As New StringWriter()

Dim htw As New System.Web.UI.HtmlTextWriter(sw)

EnableViewState = False

gv.RenderControl(htw)

Response.Write(sw.ToString())

Response.End()
"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
"David C" <dl*****@lifetimeinc.comwrote in message
news:ua**************@TK2MSFTNGP05.phx.gbl...
>>I have an ASP.Net 2.0 intranet application and would like to be able to
send a name and address to an msword content type or something. I want to
first just send out the person's name and address to the upper-left
portion of the newly created .doc format so the user can finish the letter
and save/print the letter. I have done some exporting to Excel from a
GridView but I'm not sure how to create in Word.

All users have Microsoft Word and IE6+. Thanks.

Firstly, under no circumstances attempt to do Office automation in
ASP.NET - it's not supported by Microsoft because it's just not designed
to work in this environment:
http://support.microsoft.com/default...US;q257757#kb2

Luckily, your requirements do not require automation, and are extremely
simple.

Basically, just create an HTML document and then save it with a .doc
extension.

As an example, open Notepad, paste the text below, and then save it as
Bill.doc

<html>

<body>
Bill Gates<br />
Microsoft Corporation<br />
Redmond<br />
<br />
Dear Bill,<br />
<br />
</body>

</html>
Now double-click the newly created "Word" document - Word will treat it
just like a native Word document.

Apr 23 '07 #3
Here are some details on generating Word (and Excel) documents:
http://SteveOrr.net/articles/ExcelExport.aspx
http://SteveOrr.net/articles/ExportPanel.aspx

Here are some decent 3rd party options that could help speed your
development:
http://SteveOrr.net/reviews/AsposeWord.aspx
http://SteveOrr.net/reviews/OfficeWriter.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"David C" <dl*****@lifetimeinc.comwrote in message
news:ua**************@TK2MSFTNGP05.phx.gbl...
>I have an ASP.Net 2.0 intranet application and would like to be able to
send a name and address to an msword content type or something. I want to
first just send out the person's name and address to the upper-left portion
of the newly created .doc format so the user can finish the letter and
save/print the letter. I have done some exporting to Excel from a GridView
but I'm not sure how to create in Word.

All users have Microsoft Word and IE6+. Thanks.

David
Apr 23 '07 #4

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

Similar topics

1
by: coder_1024 | last post by:
I'm trying to send a packet of binary data to a UDP server. If I send a text string, it works fine. If I attempt to send binary data, it sends a UDP packet with 0 bytes of data (just the...
7
by: MouseHart | last post by:
I have written a small VB program which lists my music files on my computer, but I can't get it to print exactly the way I want it to. The data is viewed on screen in an MSFlexGrid named...
2
by: Marre | last post by:
Hi all! I would like to get data from a webform, push a button and fire up Word. Here i would like to retrieve data from my webform. Is there a way to do this without using chrystal reports? ...
6
by: Eduardo Rosa | last post by:
Somebody knows how I queue email using .Net? thanks a lot
1
by: Derek | last post by:
I have a simple app that logs details of my customers and the work done for them. It uses a few tables in Access and allows me to keep a basic record of things for my accountant. How can I...
7
by: D. Patrick | last post by:
I need to duplicate the functionality of a java applet, and how it connects to a remote server. But, I don't have the protocol information or the java source code which was written years ago. ...
9
by: Miro | last post by:
VB 2003 at the end of the code, this works great. bytCommand = Encoding.ASCII.GetBytes("testing hello send text") udpClient.Send(bytCommand, bytCommand.Length) and this recieves it Dim...
0
by: Andrea | last post by:
Hi I've having a very strange problem using the SendInput API to send text to other applications. I've written the code and it seems to work well. I discovered a strange problem: when I try to...
2
by: Alex Bryan | last post by:
Okay, so what I want to do is connect to dictionary.com and send the website a word, and later receive the definition. But for now, I want to focus on sending the word. A good guy from this mailing...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.