Can't able to Open Word File in Client Machine

Author Topic
Senthil V
Member

Joined: 31 May 2006
Country: India
Posts: 5

Posted: 05 Jun 2006 12:58:16

Hi,

Im having word document in the Server Machine. While im trying to open the file in Client Machine file is opening in Server only. I need to open in the client only. This is an ASP.NET project done in VB.NET.

The Code i used to Open the file
---------------------------------------------
Dim oWordApplic As New Word.ApplicationClass
Dim oDoc As Word.Document
Dim strFileName As String = ConfigurationSettings.AppSettings("ServerWordDocu" + ReportName + ".doc"
Dim fileName As String = strFileName
oWordApplic.Visible = True
oDoc = oWordApplic.Documents.Open(fileName)
oDoc.Activate()
----------------------------------------------------------------

Another Code I Used is Hyperlink. Just i give the link to hyperlink but its opening in readonly format. so i cant able to do any modification. Because i have to save the file in the server.

HyperLink1.Text = Name + ".doc"
HyperLink1.NavigateUrl = ConfigurationSettings.AppSettings("WordDocu" + Name + ".doc"
----------------------------------------------------------------

Another type i Checked its also opening in readonly.

Dim filename As String = ConfigurationSettings.AppSettings("WordDocu" + ReportName + ".doc"
Response.ContentType = "application/ms-word"
Response.AddHeader("ContentDisposition", "attachment;filename"
Response.WriteFile(filename)


Give me the solution i need it very urgent to implement in project.

Thanks in advance
Senthil V.

Senthil V

Hi,

Im having word document in the Server Machine. While im trying to open the file in Client Machine file is opening in Server only. I need to open in the client only. This is an ASP.NET project done in VB.NET.

The Code i used to Open the file
---------------------------------------------
Dim oWordApplic As New Word.ApplicationClass
Dim oDoc As Word.Document
Dim strFileName As String = ConfigurationSettings.AppSettings("ServerWordDocu" + ReportName + ".doc"
Dim fileName As String = strFileName
oWordApplic.Visible = True
oDoc = oWordApplic.Documents.Open(fileName)
oDoc.Activate()
----------------------------------------------------------------

Another Code I Used is Hyperlink. Just i give the link to hyperlink but its opening in readonly format. so i cant able to do any modification. Because i have to save the file in the server.

HyperLink1.Text = Name + ".doc"
HyperLink1.NavigateUrl = ConfigurationSettings.AppSettings("WordDocu" + Name + ".doc"
----------------------------------------------------------------

Another type i Checked its also opening in readonly.

Dim filename As String = ConfigurationSettings.AppSettings("WordDocu" + ReportName + ".doc"
Response.ContentType = "application/ms-word"
Response.AddHeader("ContentDisposition", "attachment;filename"
Response.WriteFile(filename)


Give me the solution i need it very urgent to implement in project.

Thanks in advance
Senthil V.

Senthil V
Yannick Arekion
Member

Joined: 14 Jun 2006
Country:
Posts: 2

Posted: 17 Jun 2006 10:31:23

Try to use Response.Redirect(url)

where url is the url of the word document.

Try to use Response.Redirect(url)

where url is the url of the word document.

eshwar ch
Member

Joined: 15 Oct 2008
Country: India
Posts: 1

Posted: 15 Oct 2008 10:31:04


hi Senthil V.


i am also facing same problem. if u have solution please send it asap.

Thanks,
Eshwar.Ch


<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hi,

Im having word document in the Server Machine. While im trying to open the file in Client Machine file is opening in Server only. I need to open in the client only. This is an ASP.NET project done in VB.NET.

The Code i used to Open the file
---------------------------------------------
Dim oWordApplic As New Word.ApplicationClass
Dim oDoc As Word.Document
Dim strFileName As String = ConfigurationSettings.AppSettings("ServerWordDocu" + ReportName + ".doc"
Dim fileName As String = strFileName
oWordApplic.Visible = True
oDoc = oWordApplic.Documents.Open(fileName)
oDoc.Activate()
----------------------------------------------------------------

Another Code I Used is Hyperlink. Just i give the link to hyperlink but its opening in readonly format. so i cant able to do any modification. Because i have to save the file in the server.

HyperLink1.Text = Name + ".doc"
HyperLink1.NavigateUrl = ConfigurationSettings.AppSettings("WordDocu" + Name + ".doc"
----------------------------------------------------------------

Another type i Checked its also opening in readonly.

Dim filename As String = ConfigurationSettings.AppSettings("WordDocu" + ReportName + ".doc"
Response.ContentType = "application/ms-word"
Response.AddHeader("ContentDisposition", "attachment;filename"
Response.WriteFile(filename)


Give me the solution i need it very urgent to implement in project.

Thanks in advance
Senthil V.

Senthil V
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

eshwar


hi Senthil V.


i am also facing same problem. if u have solution please send it asap.

Thanks,
Eshwar.Ch


<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hi,

Im having word document in the Server Machine. While im trying to open the file in Client Machine file is opening in Server only. I need to open in the client only. This is an ASP.NET project done in VB.NET.

The Code i used to Open the file
---------------------------------------------
Dim oWordApplic As New Word.ApplicationClass
Dim oDoc As Word.Document
Dim strFileName As String = ConfigurationSettings.AppSettings("ServerWordDocu" + ReportName + ".doc"
Dim fileName As String = strFileName
oWordApplic.Visible = True
oDoc = oWordApplic.Documents.Open(fileName)
oDoc.Activate()
----------------------------------------------------------------

Another Code I Used is Hyperlink. Just i give the link to hyperlink but its opening in readonly format. so i cant able to do any modification. Because i have to save the file in the server.

HyperLink1.Text = Name + ".doc"
HyperLink1.NavigateUrl = ConfigurationSettings.AppSettings("WordDocu" + Name + ".doc"
----------------------------------------------------------------

Another type i Checked its also opening in readonly.

Dim filename As String = ConfigurationSettings.AppSettings("WordDocu" + ReportName + ".doc"
Response.ContentType = "application/ms-word"
Response.AddHeader("ContentDisposition", "attachment;filename"
Response.WriteFile(filename)


Give me the solution i need it very urgent to implement in project.

Thanks in advance
Senthil V.

Senthil V
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

eshwar
praveen khade
Member

Joined: 26 Mar 2008
Country: India
Posts: 2

Posted: 18 Feb 2009 12:36:26

object missing = System.Reflection.Missing.Value;
object Visible = true;
object start1 = 0;
object end1 = 0;
ApplicationClass WordApp = new ApplicationClass();
Document adoc = WordApp.Documents.Add(ref missing, ref missing, ref missing, ref missing);
Range rng = adoc.Range(ref start1, ref missing);
rng.Font.Name = "Georgia";
rng.InsertAfter("Hello World!";
object filename = @"E:\MyWord.doc";
adoc.SaveAs(ref filename, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
WordApp.Visible = true;

object missing = System.Reflection.Missing.Value;
object Visible = true;
object start1 = 0;
object end1 = 0;
ApplicationClass WordApp = new ApplicationClass();
Document adoc = WordApp.Documents.Add(ref missing, ref missing, ref missing, ref missing);
Range rng = adoc.Range(ref start1, ref missing);
rng.Font.Name = "Georgia";
rng.InsertAfter("Hello World!";
object filename = @"E:\MyWord.doc";
adoc.SaveAs(ref filename, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
WordApp.Visible = true;

praveen khade
Member

Joined: 26 Mar 2008
Country: India
Posts: 2

Posted: 18 Feb 2009 12:38:26

Or u can take this sample

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Word = Microsoft.Office.Interop.Word;

namespace reading
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void btnopen_Click(object sender, EventArgs e)
{
object fileName = @txtFilePath.Text;
object oNull = System.Reflection.Missing.Value;
object doNotSaveChanges = Word.WdSaveOptions.wdDoNotSaveChanges;
Word.Application oApp = new Microsoft.Office.Interop.Word.Application();
Word.Document oDoc = oApp.Documents.Open(ref fileName, ref oNull, ref oNull,ref oNull, ref oNull, ref oNull, ref oNull, ref oNull, ref oNull,ref oNull, ref oNull, ref oNull, ref oNull, ref oNull, ref oNull, ref oNull);
oApp.Visible = false;
this.richTextBox1.Text = oDoc.Content.Text;
oDoc.Close(ref doNotSaveChanges, ref oNull, ref oNull);
oDoc = null;
oApp.Quit(ref doNotSaveChanges, ref oNull, ref oNull);
oApp = null;

}

private void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
}

private void btnbrowse_Click(object sender, EventArgs e)
{
openFileDialog1.CheckFileExists = true;
openFileDialog1.CheckPathExists = true;

openFileDialog1.Filter = "Word Document Files Only (*.doc)|*.doc";
openFileDialog1.FilterIndex = 0;

openFileDialog1.Multiselect = false;

openFileDialog1.ReadOnlyChecked = false;
openFileDialog1.ShowReadOnly = false;
openFileDialog1.Title = "Select Word Document to 'Read'.";
DialogResult oResult = openFileDialog1.ShowDialog();


if (oResult == DialogResult.OK)
{
this.txtFilePath.Text = openFileDialog1.FileName;
}
else
{
this.txtFilePath.Text = String.Empty;
}

}
}
}

Or u can take this sample

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Word = Microsoft.Office.Interop.Word;

namespace reading
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void btnopen_Click(object sender, EventArgs e)
{
object fileName = @txtFilePath.Text;
object oNull = System.Reflection.Missing.Value;
object doNotSaveChanges = Word.WdSaveOptions.wdDoNotSaveChanges;
Word.Application oApp = new Microsoft.Office.Interop.Word.Application();
Word.Document oDoc = oApp.Documents.Open(ref fileName, ref oNull, ref oNull,ref oNull, ref oNull, ref oNull, ref oNull, ref oNull, ref oNull,ref oNull, ref oNull, ref oNull, ref oNull, ref oNull, ref oNull, ref oNull);
oApp.Visible = false;
this.richTextBox1.Text = oDoc.Content.Text;
oDoc.Close(ref doNotSaveChanges, ref oNull, ref oNull);
oDoc = null;
oApp.Quit(ref doNotSaveChanges, ref oNull, ref oNull);
oApp = null;

}

private void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
}

private void btnbrowse_Click(object sender, EventArgs e)
{
openFileDialog1.CheckFileExists = true;
openFileDialog1.CheckPathExists = true;

openFileDialog1.Filter = "Word Document Files Only (*.doc)|*.doc";
openFileDialog1.FilterIndex = 0;

openFileDialog1.Multiselect = false;

openFileDialog1.ReadOnlyChecked = false;
openFileDialog1.ShowReadOnly = false;
openFileDialog1.Title = "Select Word Document to 'Read'.";
DialogResult oResult = openFileDialog1.ShowDialog();


if (oResult == DialogResult.OK)
{
this.txtFilePath.Text = openFileDialog1.FileName;
}
else
{
this.txtFilePath.Text = String.Empty;
}

}
}
}

Follow us on twitter Subscribe to our RSS feed
Activate your free membership today | Login | Currency