|
-
Jan 27th, 2003, 02:47 AM
#1
Thread Starter
Junior Member
Retrieving text from MS Word document
I need to retrieve all text from MS Word document where word style is Heading 1, and show that on text box. Anyone know how to recognize what word style is used on some place in Word Document?
I know how to open document, or find a text, but how to find which word style is used. I try something like:
If objWord.ActiveDocument.Paragraph.Item(i).Style = "Normal" Then ....
but doesnt work.
I get error:
Additional information: Operator is not valid for type 'Style' and string "Normal".
That code works fine in Visual Basic 6
-
Jan 27th, 2003, 02:55 AM
#2
Registered User
Haven't tried this myself, but I think its a fair guess.....
Code:
If Selection.Style = ActiveDocument.Styles("Normal") Then
-
Jan 27th, 2003, 03:28 AM
#3
Thread Starter
Junior Member
There is no error
Thanks a lot Athley.
With:
objWord.Selection.Find.Style = "Heading 1"
x = Selection.text
Give me only the first character of paragraph. Is it possible to select whole paragraph when I find style?
-
Jan 27th, 2003, 03:38 AM
#4
Registered User
Again I haven't tried it....
Code:
Selection.Expand (wdParagraph)
You probably have to retrieve the Selection.Text after that as well...
-
Jan 27th, 2003, 03:47 AM
#5
Thread Starter
Junior Member
I find it!!!
Thanks again Athley
There is vb.net code if someone need the same thing:
PHP Code:
objWord.Selection.Find.Style = "Normal"
objWord.Selection.Find.Execute(FindText:="", Format:=True, _
Forward:=True, Wrap:=Word.WdFindWrap.wdFindStop)
MsgBox(objWord.Selection.Text)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|