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

Opening Word from .net

I can't seem to open a word document from any of my browsers except the one
on my web server.

Here is the .aspx file:

************************************************** ***************
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ import Namespace="System.IO" %>

<Script Runat="Server">

Sub Page_Load
Dim conPubs As SqlConnection
Dim cmdSelect As SqlCommand
Dim dtrAuthors As SqlDataReader

' Retrieve records from database
conPubs = New SqlConnection(
System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING
_Contour_Server"))
cmdSelect = New SqlCommand( "Select title,fullFileName From
openworx..QADocs order by title", conPubs )
conPubs.Open()
dtrAuthors = cmdSelect.ExecuteReader()

' Bind to Repeater
rptAuthors.DataSource = dtrAuthors
rptAuthors.DataBind()

dtrAuthors.Close()
conPubs.Close()
End Sub

</Script>

<html>
<head><title>Repeater.aspx</title></head>
<body>
<form Runat="Server">

<asp:Repeater
ID="rptAuthors"
Runat="Server">

<ItemTemplate>
<a href="<%# Container.DataItem("fullFileName") %>" ><%#
Container.DataItem("title") %></a><br>
</ItemTemplate>

<separatortemplate>
<hr></separatortemplate>

</asp:Repeater>

</form>
</body>
</html>
************************************************** **************************
*******

This gives me a list of files from my QADocs table that generates a page
like so:

************************************************** **************************
*****
<html>
<head><title>Repeater.aspx</title></head>
<body>
<form name="_ctl0" method="post" action="TMPbxwz1g6rr.aspx" id="_ctl0">
<input type="hidden" name="__VIEWSTATE" value="dDwtMjA0Nr9vNNYoX" />

<a href="c:\QA Docs\QSF 6.1.4 - Acknowledgmnt of Designated Reading.doc"
Acknowledgement of Designated Reading</a><br>


<hr>

</form>
</body>
</html>
************************************************** **************************
**************

The link looks like this:

file:///c:/QA%20Docs/QSF%206.1.4%20-%20Acknowledgmnt%20of%20Designated%20Rea
ding.doc

As I said when I click on the link, a page opens up as a word document on
the web server, but not on any other workstation. It just sits there. How
do I get it to open the file?

Also, is there a way to tell the link to open up the file in a separate
window as well as to be read only?

Thanks,

Tom.
Nov 18 '05 #1
4 1728
Hi Tom:

To open a link in a new window, add target="_blank" as an attribute to
the href.

When you use an href like a href="c:\QA Docs\mydoc.doc", you are
telling the browser to open a docunment on the local drive C. Since
only the web server has the document on the C drive, it only works
from a browser on the server. When a remote client clicks the link the
browser tries to find the document on the remote machine's C drive.

You could keep the .doc files inside a virtual directory on your
weberver and provide a link with an HTTP URL.

HTH,

--
Scott
http://www.OdeToCode.com

On Mon, 26 Jul 2004 01:26:22 -0700, "Thomas Scheiderich"
<tf*@deltanet.com> wrote:
I can't seem to open a word document from any of my browsers except the one
on my web server.

Here is the .aspx file:

************************************************* ****************
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ import Namespace="System.IO" %>

<Script Runat="Server">

Sub Page_Load
Dim conPubs As SqlConnection
Dim cmdSelect As SqlCommand
Dim dtrAuthors As SqlDataReader

' Retrieve records from database
conPubs = New SqlConnection(
System.Configuration.ConfigurationSettings.AppSet tings("MM_CONNECTION_STRING
_Contour_Server"))
cmdSelect = New SqlCommand( "Select title,fullFileName From
openworx..QADocs order by title", conPubs )
conPubs.Open()
dtrAuthors = cmdSelect.ExecuteReader()

' Bind to Repeater
rptAuthors.DataSource = dtrAuthors
rptAuthors.DataBind()

dtrAuthors.Close()
conPubs.Close()
End Sub

</Script>

<html>
<head><title>Repeater.aspx</title></head>
<body>
<form Runat="Server">

<asp:Repeater
ID="rptAuthors"
Runat="Server">

<ItemTemplate>
<a href="<%# Container.DataItem("fullFileName") %>" ><%#
Container.DataItem("title") %></a><br>
</ItemTemplate>

<separatortemplate>
<hr></separatortemplate>

</asp:Repeater>

</form>
</body>
</html>
************************************************* ***************************
*******

This gives me a list of files from my QADocs table that generates a page
like so:

************************************************* ***************************
*****
<html>
<head><title>Repeater.aspx</title></head>
<body>
<form name="_ctl0" method="post" action="TMPbxwz1g6rr.aspx" id="_ctl0">
<input type="hidden" name="__VIEWSTATE" value="dDwtMjA0Nr9vNNYoX" />

<a href="c:\QA Docs\QSF 6.1.4 - Acknowledgmnt of Designated Reading.doc"
Acknowledgement of Designated Reading</a><br>


<hr>

</form>
</body>
</html>
************************************************* ***************************
**************

The link looks like this:

file:///c:/QA%20Docs/QSF%206.1.4%20-%20Acknowledgmnt%20of%20Designated%20Rea
ding.doc

As I said when I click on the link, a page opens up as a word document on
the web server, but not on any other workstation. It just sits there. How
do I get it to open the file?

Also, is there a way to tell the link to open up the file in a separate
window as well as to be read only?

Thanks,

Tom.


Nov 18 '05 #2
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:f8********************************@4ax.com...
Hi Tom:

To open a link in a new window, add target="_blank" as an attribute to
the href.

That was what I was looking for.
When you use an href like a href="c:\QA Docs\mydoc.doc", you are
telling the browser to open a docunment on the local drive C. Since
only the web server has the document on the C drive, it only works
from a browser on the server. When a remote client clicks the link the
browser tries to find the document on the remote machine's C drive.

You could keep the .doc files inside a virtual directory on your
weberver and provide a link with an HTTP URL.
I was told it was dangerous to put Documents in a vitual directory as that
would leave them vulnerable. This was why I did it this way.

However, by doing this - it now works - as long as the person has Word on
his machine.

Is there a way to have the browser send the file already word formatted? If
there is no word on the machine, it displayes it as a text file which will
have all non text displayed as ascii and boxes (for non printable
characters).

Thanks,

Tom.
HTH,

--
Scott
http://www.OdeToCode.com

On Mon, 26 Jul 2004 01:26:22 -0700, "Thomas Scheiderich"
<tf*@deltanet.com> wrote:
I can't seem to open a word document from any of my browsers except the one
on my web server.

Here is the .aspx file:

************************************************* ****************
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ import Namespace="System.IO" %>

<Script Runat="Server">

Sub Page_Load
Dim conPubs As SqlConnection
Dim cmdSelect As SqlCommand
Dim dtrAuthors As SqlDataReader

' Retrieve records from database
conPubs = New SqlConnection(


System.Configuration.ConfigurationSettings.AppSet tings("MM_CONNECTION_STRIN

G
_Contour_Server"))
cmdSelect = New SqlCommand( "Select title,fullFileName From
openworx..QADocs order by title", conPubs )
conPubs.Open()
dtrAuthors = cmdSelect.ExecuteReader()

' Bind to Repeater
rptAuthors.DataSource = dtrAuthors
rptAuthors.DataBind()

dtrAuthors.Close()
conPubs.Close()
End Sub

</Script>

<html>
<head><title>Repeater.aspx</title></head>
<body>
<form Runat="Server">

<asp:Repeater
ID="rptAuthors"
Runat="Server">

<ItemTemplate>
<a href="<%# Container.DataItem("fullFileName") %>" ><%#
Container.DataItem("title") %></a><br>
</ItemTemplate>

<separatortemplate>
<hr></separatortemplate>

</asp:Repeater>

</form>
</body>
</html>


************************************************* **************************

*
*******

This gives me a list of files from my QADocs table that generates a page
like so:


************************************************* **************************

*
*****
<html>
<head><title>Repeater.aspx</title></head>
<body>
<form name="_ctl0" method="post" action="TMPbxwz1g6rr.aspx" id="_ctl0">
<input type="hidden" name="__VIEWSTATE" value="dDwtMjA0Nr9vNNYoX" />

<a href="c:\QA Docs\QSF 6.1.4 - Acknowledgmnt of Designated Reading.doc"
Acknowledgement of Designated Reading</a><br>


<hr>

</form>
</body>
</html>


************************************************* **************************

***************

The link looks like this:


file:///c:/QA%20Docs/QSF%206.1.4%20-%20Acknowledgmnt%20of%20Designated%20Re

a
ding.doc

As I said when I click on the link, a page opens up as a word document on
the web server, but not on any other workstation. It just sits there. Howdo I get it to open the file?

Also, is there a way to tell the link to open up the file in a separate
window as well as to be read only?

Thanks,

Tom.

Nov 18 '05 #3
Hi Tom:

I think if I had to display Word as text, I would have a batch process
on the server converting Word .doc files to text files. I know there
are some third party components to do this, perhaps there are even
some free ones.

Another option you might consider is linking to the free Word document
viewer:
http://www.microsoft.com/downloads/d...displaylang=EN

--s
On Mon, 26 Jul 2004 09:46:16 -0700, "Thomas Scheiderich"
<tf*@deltanet.com> wrote:

<snip>

Is there a way to have the browser send the file already word formatted? If
there is no word on the machine, it displayes it as a text file which will
have all non text displayed as ascii and boxes (for non printable
characters).

Thanks,

Tom.


--
Scott
http://www.OdeToCode.com
Nov 18 '05 #4
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:63********************************@4ax.com...
Hi Tom:

I think if I had to display Word as text, I would have a batch process
on the server converting Word .doc files to text files. I know there
are some third party components to do this, perhaps there are even
some free ones.
I actually didn't want to convert them to text files, just wanted to send
them already formatted to the users machine, which may not be possible (or
plauseable) - especially with the tables and images and special formatting
and spacing.
Another option you might consider is linking to the free Word document
viewer:
http://www.microsoft.com/downloads/d...E60-E4F3-436D-
A5A7-DA0E5431E5C1&displaylang=EN This looks interesting. I do remember somewhere that there was a way to put
a word document in an IFrame (which put all the normal window controls
around the Iframe. Not sure where I saw that, however.

Still can't figure out how to open the file as readonly. I suppose the only
way to do this is to actually set the file to readonly in Windows Explorer.

Thanks,

Tom. --s
On Mon, 26 Jul 2004 09:46:16 -0700, "Thomas Scheiderich"
<tf*@deltanet.com> wrote:

<snip>

Is there a way to have the browser send the file already word formatted? Ifthere is no word on the machine, it displayes it as a text file which willhave all non text displayed as ascii and boxes (for non printable
characters).

Thanks,

Tom.


--
Scott
http://www.OdeToCode.com

Nov 18 '05 #5

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

Similar topics

5
by: Vinay | last post by:
Hi I have a corrupt word file. I am able to open it with the code given below tr Dim pInfo As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo( pInfo.UseShellExecute...
0
by: Sivaraman.S | last post by:
Issue: When I am opening a word document or a template from an ASP.NET Web page (language used VB.NET Visual Studio Version 2003) using Word.ApplicationClass object (Reference Word 11.0 object...
1
by: Andy Davis | last post by:
Hi I've written the following code for a button on a form to open a mail merge document in MS Word. The code opens the document fine but does not display the usual connection details to open the...
3
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge...
0
by: Sivaraman.S | last post by:
Issue : When I am trying to open a Word Document or a Template from a Web Application (ASP.NET Web page - Language Used VB.NET Visual Studio Version 2003) using Word.ApplicationClass (Refering...
1
by: ourspt | last post by:
Hi, We are working on an ASP.NET (VB.NET) application and we have a problem opening a word document from our application. When we try to open the word document, we do not get any error...
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...
5
by: Cedric | last post by:
Hi Folks, I'm wondering if someone has already succeed to open a word2000 document located on server side with javascript code executed by a web browser on client side. In fact, i make it...
2
by: DigitalFusion | last post by:
Hello All, I have an app on an intranet which uses the response.contenttype in ASP to create a word doc. The issue I am having is that when this doc is generated and opened, the session is...
1
navanova
by: navanova | last post by:
Greetings, I have a problem of opening ms word and excel files on my computer. The files are there for a long time. I use to open and modify them. Suddenly, when i try to open the word files, a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.