473,385 Members | 1,546 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,385 software developers and data experts.

how to read word document in ASP.Net & C#

Jay
Hi,
I need to read word document file in ASP.net and place it in a text
box .
How to do it ? i tried :

Word.Application app = new Word.ApplicationClass();
object nullobj = System.Reflection.Missing.Value;
object file = @"C:\Suneetha\Ques.doc";
Word.Document doc = app.Documents.Open(
ref file, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj);
doc.ActiveWindow.Selection.WholeStory();
doc.ActiveWindow.Selection.Copy();
IDataObject data = Clipboard.GetDataObject();
string text = data.GetData(DataFormats.Text).ToString();
Console.WriteLine(text);
doc.Close(ref nullobj, ref nullobj, ref nullobj);
app.Quit(ref nullobj, ref nullobj, ref nullobj);

but i got few error :

" No overload for method 'Open' takes '15' arguments "

is there any toehr way to read a word document file ?
waiting for ur replay ,

Thanks,
Jay

Aug 4 '06 #1
3 9744
It sounds like you are real close. How many arguments does the .Open( take
when you delete and the retype the first ( after the open?

If you are pasting code in from a sample on the net, sometimes that doesn't
work. This is because you are using early binding for your Word automation
with the code you have and your .olb may not be the same version the example
was written from.

Opens from version 9 and 11 have different number of arguments. If you are
using 9, you should only have 12 arguments.

Ex)
oWordDoc = WordApplicationInstance.Documents.Open(ref fileName, ref missing,
ref readOnly, ref missing, ref missing, ref missing,
ref missing, ref
missing, ref missing,
ref missing, ref missing, ref missing);

Thanks,

Rob K
Hi,
I need to read word document file in ASP.net and place it in a text
box .
How to do it ? i tried :

Word.Application app = new Word.ApplicationClass();
object nullobj = System.Reflection.Missing.Value;
object file = @"C:\Suneetha\Ques.doc";
Word.Document doc = app.Documents.Open(
ref file, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj);
doc.ActiveWindow.Selection.WholeStory();
doc.ActiveWindow.Selection.Copy();
IDataObject data = Clipboard.GetDataObject();
string text = data.GetData(DataFormats.Text).ToString();
Console.WriteLine(text);
doc.Close(ref nullobj, ref nullobj, ref nullobj);
app.Quit(ref nullobj, ref nullobj, ref nullobj);

but i got few error :

" No overload for method 'Open' takes '15' arguments "

is there any toehr way to read a word document file ?
waiting for ur replay ,

Thanks,
Jay

Aug 4 '06 #2
U r right Rob,
Here is the code that i did and that might help some one:

Word.ApplicationClass wordApp = new Word.ApplicationClass();
string filePath = inputbox.Value;
object file = filePath;
object nullobj = System.Reflection.Missing.Value;
Word.Document doc = wordApp.Documents.Open(ref file, ref
nullobj, ref nullobj,
ref nullobj, ref nullobj,
ref nullobj,
ref nullobj, ref nullobj,
ref nullobj,
ref nullobj, ref nullobj,
ref nullobj);

Word.Document doc1 = wordApp.ActiveDocument;
string m_Content = doc1.Content.Text;
m_Resume.Text = m_Content;
doc.Close(ref nullobj, ref nullobj, ref nullobj);

it works cool ..
Guys,any doubs do message me ...

Ciao,
Jayender
RobKinney1 wrote:
It sounds like you are real close. How many arguments does the .Open( take
when you delete and the retype the first ( after the open?

If you are pasting code in from a sample on the net, sometimes that doesn't
work. This is because you are using early binding for your Word automation
with the code you have and your .olb may not be the same version the example
was written from.

Opens from version 9 and 11 have different number of arguments. If you are
using 9, you should only have 12 arguments.

Ex)
oWordDoc = WordApplicationInstance.Documents.Open(ref fileName, ref missing,
ref readOnly, ref missing, ref missing, ref missing,
ref missing, ref
missing, ref missing,
ref missing, ref missing, ref missing);

Thanks,

Rob K
Hi,
I need to read word document file in ASP.net and place it in a text
box .
How to do it ? i tried :

Word.Application app = new Word.ApplicationClass();
object nullobj = System.Reflection.Missing.Value;
object file = @"C:\Suneetha\Ques.doc";
Word.Document doc = app.Documents.Open(
ref file, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj);
doc.ActiveWindow.Selection.WholeStory();
doc.ActiveWindow.Selection.Copy();
IDataObject data = Clipboard.GetDataObject();
string text = data.GetData(DataFormats.Text).ToString();
Console.WriteLine(text);
doc.Close(ref nullobj, ref nullobj, ref nullobj);
app.Quit(ref nullobj, ref nullobj, ref nullobj);

but i got few error :

" No overload for method 'Open' takes '15' arguments "

is there any toehr way to read a word document file ?
waiting for ur replay ,

Thanks,
Jay
Aug 5 '06 #3
Nice job! If you want, you can click the Yes button under the "Did this
answer you question" note under the last post I made so people know this
thread is answered.

Happy Programming! :~}

Rob K

"Jayender" wrote:
U r right Rob,
Here is the code that i did and that might help some one:

Word.ApplicationClass wordApp = new Word.ApplicationClass();
string filePath = inputbox.Value;
object file = filePath;
object nullobj = System.Reflection.Missing.Value;
Word.Document doc = wordApp.Documents.Open(ref file, ref
nullobj, ref nullobj,
ref nullobj, ref nullobj,
ref nullobj,
ref nullobj, ref nullobj,
ref nullobj,
ref nullobj, ref nullobj,
ref nullobj);

Word.Document doc1 = wordApp.ActiveDocument;
string m_Content = doc1.Content.Text;
m_Resume.Text = m_Content;
doc.Close(ref nullobj, ref nullobj, ref nullobj);

it works cool ..
Guys,any doubs do message me ...

Ciao,
Jayender
Aug 6 '06 #4

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

Similar topics

0
by: Chris J | last post by:
Hi all, ] I'm having a problem with Word 2002 when downloading a Word document with IE6. This is in an intranet application, and the download occurs through an ASP that does security checks...
1
by: msdn | last post by:
hi it is possible to open word document in RichTextBox(textarea) ? but i don't want to install MsWord, i want only open document, inesert some text and save it. do you know how to do this ?...
8
by: Tim Murphy | last post by:
How do you read/write a Word document embedded in an OLE Object field in an Access table with VB.NET? I have an Access application where users are creating and editing Word documents that are...
5
by: JohnSouth | last post by:
Hi I've seen lots of posts around this subject but nothing recent or very helpful. I've an ASP.Net c# application that needs to read Word documents from a directory on the web server, open...
3
by: Bishman | last post by:
Hi, I have some issues with the code below. These are: ONE: In code I open an existing document and 'attach' the Mail Merge data source, but the data is not poulating the merge fields...
5
by: sajithkahawatta | last post by:
i wrote a code to read a doc in asp.net i woked properly in my iis ms word is installed in this pc. but when i published in another sever in which there is no ms word instslled it give error in it...
0
by: dotNetDummi | last post by:
Hi experts, I have a task to print some data into a word document .I need to set the word document to readOnly. It's working but user still can edit. Is there any thing I can do whereby user...
0
by: Srinivas Dammalapa | last post by:
Sir, I am D.Srinivas. I am working on JobPortal Website(www.tlabsinc.com). I am downloading MS-Word document using ASP.NET 2.0 & C# 2.0. I am using IE (Internet Explorer). In my...
6
by: Paul Mc | last post by:
Hi all, It's a little late in the day for me so please forgive as i need my bed.!! The issue is i need to open a word doc (say "c:\temp.doc) and paste into it, but i only can work out how...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.