473,385 Members | 1,587 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 9745
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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
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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.