Smart Device
Visual C#
VS Team System
Visual Basic
.NET Development
SQL Server
Windows Vista
Visual Studio
VS Express Editions
Microsoft ISV
Game Technologies
Windows Live
Visual J#
Visual C++
Windows Forms
Software Development Network>> Microsoft ISV>> Select line of text in Word documents
Select line of text in Word documents
Hot Topic
Publishing Scorecard in BSM
"Custom" properties of office and other files...
macro still does not fire??
Access/VBA add the value to ListBox every column
VS2005: Any more CTP or RC builds to come?
Controlling a Word Mail Merge with Excel
Help with DDEExecute
How do I avoid multiple instances of Excel
Buddy hasn't contacted me yet...
Closing a dependent file in Excel97
Microsoft ISV
Excel, Forms, and Charts
What's your experience with the buddy program?
Can you guys help me fixing the error?
Is there a way to select..
Social/Ethical Question!
Roll-up KPI indicators to Objectives Doesn't work
Business Scorecard 2005 Installed - Just cannot connect to Analysis Services database
Sendin an Email through Excell, without attach the file
InlineShape.AddOLEObject method formatting wrong
Inaccurate double variables in VBA!!!
Select line of text in Word documents
How can I "Select a line of text in Word documents" to futher manipulate it I figured how to do individual Words, but I'd like to select a line ot text containing a certain word.
Answer this question
Select line of text in Word documents
Soroush Atarod
Not too sure how to select a line of text, but this will select the sentence containing the word:
Sub SelectSentence()
Dim oDoc As Word.Document
Set oDoc = Documents.Open("C:\documents and settings\mydocument")
With Selection.Find
.Text = InputBox("Enter word to find")
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute
If .Found Then
Selection.Extend
Selection.Extend
Selection.Extend
MsgBox Selection
End If
oDoc.Close
Set oDoc = Nothing
End With
End Sub
Select line of text in Word documents
Answer this question
Select line of text in Word documents
Soroush Atarod
Sub SelectSentence()
Dim oDoc As Word.Document
Set oDoc = Documents.Open("C:\documents and settings\mydocument")
With Selection.Find
.Text = InputBox("Enter word to find")
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute
If .Found Then
Selection.Extend
Selection.Extend
Selection.Extend
MsgBox Selection
End If
oDoc.Close
Set oDoc = Nothing
End With