473,499 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extract text from a Word doc

How can I open a word doc and extract the text as text without any
formatting characters??

--
Barry Fitzgerald
Nov 20 '05 #1
4 2102
Hi Barry,

Office
http://support.microsoft.com/default...b;EN-US;311452

http://msdn.microsoft.com/office/

Pia Download
http://www.microsoft.com/downloads/d...displaylang=en

Have a look at those pages

I think you find it there.

Cor
Nov 20 '05 #2
* "Barry" <ba*****@home.com> scripsit:
How can I open a word doc and extract the text as text without any
formatting characters??


Add a reference to the "Microsoft Word 10.0 Object Library"
COM component and use thide code:

\\\
Private Sub Form1_Load( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs _
) Handles MyBase.Load
Dim objWord As Word.ApplicationClass
Dim strText As String
objWord = New Word.Application()
With objWord
.Visible = False
.Documents.Open( _
Application.StartupPath & "\cookies.doc", _
, _
True _
)
.WordBasic.EditSelectAll()
.WordBasic.SetDocumentVar( _
"MyVar", _
.ActiveDocument.ActiveWindow.Selection.Text _
)
strText = .WordBasic.GetDocumentVar("MyVar")
TextBox1.Text = _
InsertNewLineChars(Strings.Left(strText, Len(strText) - 1))
.Documents.Close(0)
.Quit()
End With
End Sub

Private Function InsertNewLineChars( _
ByVal strText As String _
) As String
Dim pos As Integer, l As Integer
pos = 1
Do While pos < Len(strText)
l = Strings.InStr(pos, strText, vbCr)
If l = 0 Then Exit Do
strText = _
Strings.Left(strText, l - 1) & vbCrLf & _
Mid(strText, l + 1)
pos = l + 2
Loop
Return strText
End Function
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
Thanks, I think that will help me out enough.

--
Barry Fitzgerald
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eD**************@TK2MSFTNGP11.phx.gbl...
Hi Barry,

Office
http://support.microsoft.com/default...b;EN-US;311452

http://msdn.microsoft.com/office/

Pia Download
http://www.microsoft.com/downloads/d...displaylang=en
Have a look at those pages

I think you find it there.

Cor

Nov 20 '05 #4
* "Barry" <ba*****@home.com> scripsit:
Thanks, I think that will help me out enough.


I hope you didn't forget to take a look at the "ready-to-be-copied"
solution I posted ;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #5

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

Similar topics

1
2235
by: questioner | last post by:
Hello everyone, I want to find text and extract a rest of line after the found line till line end. Does anyone know how to do this? Regards, P.S. My code looks like this so far: word =...
1
12055
by: mickeydisn | last post by:
Sub: C++ Word automation Extract text hello. I want extact text form a word document using a visual c++ programme. I have see a lot of documentation. and my analysis is that I must use a...
3
2531
by: ano1optimist | last post by:
I've got the code to search through a directory for word documents, open the doc, search for specific text... but I'm trying to extract data that immediately follows the selected highlighted text. ...
3
30756
by: Adam Faulkner via DotNetMonster.com | last post by:
I want to create a method within a class that opens a Microsoft Word 2000 Document and has the facility to Create a new word document and then extract a Page that exists within the original Word...
8
6036
by: nick | last post by:
Hi all can any one please tell me what is wrong in this code?? I'm new to deal with text files and extract data. i'm trying to look for data in a text file (3~4 pages) some lines start with a...
7
2867
by: teo | last post by:
hallo, I need to extract a word and few text that precedes and follows it (about 30 + 30 chars) from a long textual document. Like the description that Google returns when it has found a...
2
1849
by: teo | last post by:
I have a problem (partial). Some days ago I asked for a way to extract a word and few text around it (30 chars on the left and 30 on the right) from a long text. I went good with: ...
0
2026
by: napolpie | last post by:
DISCUSSION IN USER nappie writes: Hello, I'm Peter and I'm new in python codying and I'm using parsying to extract data from one meteo Arpege file. This file is long file and it's composed by...
17
2873
by: Umesh | last post by:
Can anyone do it? ARMY1987- what say?
0
7130
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
7007
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
7171
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,...
1
6893
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...
0
7386
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
295
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.