04-08-22 12:54 AM
Dim doc As Object = GetDocument(handle,documentname)
Dim w As Object = doc.Application
Dim s As Object = w.Selection
Dim Para as Microsoft.Office.Interop.Word.Paragraph
Dim blnStart as Boolean
blnStart = false
Dim table As New System.Data.DataTable()
table.Columns.Add("Underlined_Text", GetType(String))
For Each Para In doc.Paragraphs
If Para.Range.Text.ToLower.Contains(strStartText) Then
blnStart = true
End If
If Para.Range.Font.Underline = 1 and blnStart Then
With s.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Font.Underline = 1
.Text = ""
.Replacement.Text = ""
.Format = True
.Forward = True
.Wrap = 0
.Execute
End With
.Select
table.Rows.Add(s.Range.Text)
End With
End If
If Para.Range.Text.ToLower.Contains(strEndText) Then
exit for
End If
Next Para
Underlined_Text = table
doc = Nothing
Answered! Go to Answer.
04-08-22 01:04 PM
If Para.Range.Font.Underline = 1 and blnStart Then
With s.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Font.Underline = 1
.Text = ""
.Replacement.Text = ""
.Format = True
.Forward = True
.Wrap = 0
.Execute
End With
.Select
table.Rows.Add(s.Range.Text)
End With
End If
to this:
If Para.Range.Words(1).Font.Underline = 1 and blnStart Then
With s.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Font.Underline = 1
.Text = ""
.Replacement.Text = ""
.Format = True
.Forward = True
.Wrap = 0
.Execute
End With
.Select
table.Rows.Add(s.Range.Text)
End With
End If
Notice in the If...Then that I'm specifically checking the underline format of the first word in the paragraph.
04-08-22 01:04 PM
If Para.Range.Font.Underline = 1 and blnStart Then
With s.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Font.Underline = 1
.Text = ""
.Replacement.Text = ""
.Format = True
.Forward = True
.Wrap = 0
.Execute
End With
.Select
table.Rows.Add(s.Range.Text)
End With
End If
to this:
If Para.Range.Words(1).Font.Underline = 1 and blnStart Then
With s.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Font.Underline = 1
.Text = ""
.Replacement.Text = ""
.Format = True
.Forward = True
.Wrap = 0
.Execute
End With
.Select
table.Rows.Add(s.Range.Text)
End With
End If
Notice in the If...Then that I'm specifically checking the underline format of the first word in the paragraph.
04-08-22 10:16 PM
Dim doc as Object = GetDocument(handle,documentname)
Dim Para as Microsoft.Office.Interop.Word.Paragraph
Dim table As New System.Data.DataTable()
table.Columns.Add("Underlined_Text", GetType(String))
Dim blnStart as Boolean
blnStart = false
For Each Para In doc.Paragraphs
If Para.Range.Text.ToLower.Contains(strStartText) Then
blnStart = true
End If
If Para.Range.Words(1).Font.Underline = 1 and blnStart Then
table.Rows.Add(Para.Range.Text)
End If
If Para.Range.Text.ToLower.Contains(strEndText) Then
exit for
End If
Next Para
Underlined_Text = table
04-08-22 10:36 PM
' Declare object for code use
Dim doc as Object = GetDocument(handle,document_name)
Dim w As Object = doc.Application
Dim s As Object = w.Selection
Dim Para as Object
Dim blnStart as Boolean
blnStart = false
Dim table As New System.Data.DataTable()
table.Columns.Add("Underlined_Text", GetType(String))
For Each Para In doc.Paragraphs
If Para.Range.Text.ToLower.Contains(startText) Then
blnStart = true
End If
If Para.Range.Words(1).Font.Underline = 1 and blnStart Then
With s.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Font.Underline = 1
.Text = ""
.Replacement.Text = ""
.Format = True
.Forward = True
.Wrap = 0
.Execute
End With
.Select
table.Rows.Add(s.Range.Text)
End With
End If
If Para.Range.Text.ToLower.Contains(endText) Then
Exit For
End If
Next Para
Underlined_Text = table
doc = Nothing
04-08-22 11:29 PM
05-08-22 12:08 AM
05-08-22 01:39 AM
05-08-22 01:38 PM
05-08-22 04:07 PM
05-08-22 05:45 PM
If Para.Range.Words(1).Font.Underline = 1 and blnStart Then
table.Rows.Add(Para.Range.Text)
End If