Wrox Programmer Forums
|
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 9th, 2006, 12:22 PM
Registered User
 
Join Date: Oct 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can Anybody Help Me ?

I am needing to read a Word document into VB.net Windows Application and pull out various headers, styles, and numbering from the document.

This then needs to populate a DataGrid with the information pulled out from the Word document.

Can anybody help ??

Regards
Paul :)

 
Old February 15th, 2007, 07:41 AM
Authorized User
 
Join Date: Aug 2005
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi
  First you select Microsoft Object library from Reference (This is the COM object).
  After that using the following code for opening the Word document.

Dim appWord As New Word.Application
Dim docWord As New Word.Document

docWord = appWord.Documents.Open("C:\test.doc")

After that you attached the datagrid it is automatically fethed from .doc file.


Regards
Adalarasu. S
Wipro

 
Old February 15th, 2007, 07:46 AM
Authorized User
 
Join Date: Aug 2005
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi
I had seen the following code some applications.
Plz check the following code also

Word.Application app = new Word.ApplicationClass();
//Refs to pass to the Open method for parameters we're not interested in.
object nullobj = System.Reflection.Missing.Value;

//Full file path.
object file = @"C:\MyDoc.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);

//Select and copy text to clipboard.
doc.ActiveWindow.Selection.WholeStory();
doc.ActiveWindow.Selection.Copy();

IDataObject data = Clipboard.GetDataObject();
//Do whatever with the text.
string text = data.GetData(DataFormats.Text).ToString();
Console.WriteLine(text);

//Close doc and shutdown Word application.
doc.Close(ref nullobj, ref nullobj, ref nullobj);
app.Quit(ref nullobj, ref nullobj, ref nullobj);



Regards
Adalarasu. S









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.