HardCorps88

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • in reply to: Get Highlighted Text from .docx #3471

    HardCorps88
    Participant

    Ok,
    So I got an answer off stackflow with this code.
    Still an issue with it finding my Run Properties as Nothing. WHen I open my document in OpenXml Productivity tool I see this.
    <w:p w:rsidRPr=”00AA7ABD” w:rsidR=”00710260″ w:rsidP=”00710260″ w:rsidRDefault=”006B1119″>
    <w:pPr>
    <w:spacing w:line=”240″ w:lineRule=”auto” />
    <w:ind w:firstLine=”720″ />
    <w:rPr>
    <w:highlight w:val=”yellow” />
    </w:rPr>
    </w:pPr>
    <w:proofErr w:type=”gramStart” />
    <w:r w:rsidRPr=”00AA7ABD”>
    <w:rPr>
    <w:highlight w:val=”yellow” />
    </w:rPr>
    <w:t>Zz5</w:t>
    </w:r>
    <w:r w:rsidRPr=”00AA7ABD” w:rsidR=”00710260″>
    <w:rPr>
    <w:highlight w:val=”yellow” />
    </w:rPr>
    <w:t>TT-1.</w:t>
    </w:r>
    <w:proofErr w:type=”gramEnd” />
    <w:r w:rsidRPr=”00AA7ABD” w:rsidR=”00710260″>
    <w:rPr>
    <w:highlight w:val=”yellow” />
    </w:rPr>
    <w:t xml:space=”preserve”> This is </w:t>
    </w:r>
    <w:proofErr w:type=”spellStart” />
    <w:r w:rsidRPr=”00AA7ABD” w:rsidR=”00CC1B4F”>
    <w:rPr>
    <w:highlight w:val=”yellow” />
    </w:rPr>
    <w:t>ttttt</w:t>
    </w:r>
    <w:r w:rsidRPr=”00AA7ABD” w:rsidR=”00710260″>
    <w:rPr>
    <w:highlight w:val=”yellow” />
    </w:rPr>
    <w:t>my</w:t>
    </w:r>
    <w:proofErr w:type=”spellEnd” />
    <w:r w:rsidRPr=”00AA7ABD” w:rsidR=”00710260″>
    <w:rPr>
    <w:highlight w:val=”yellow” />
    </w:rPr>
    <w:t xml:space=”preserve”> test paragraph test paragraph </w:t>
    </w:r>
    <w:proofErr w:type=”gramStart” />
    <w:r w:rsidRPr=”00AA7ABD” w:rsidR=”00710260″>
    <w:rPr>
    <w:highlight w:val=”yellow” />
    </w:rPr>
    <w:t>This</w:t>
    </w:r>
    <w:proofErr w:type=”gramEnd” />
    <w:r w:rsidRPr=”00AA7ABD” w:rsidR=”00710260″>
    <w:rPr>
    <w:highlight w:val=”yellow” />
    </w:rPr>
    <w:t xml:space=”preserve”> is my test paragraph test paragraph.</w:t>
    </w:r>
    </w:p>

    I included the snippet of code below.
    Private Function GetListOfHighlightedString(ByVal Docx As WordprocessingDocument) As List(Of String)
    Dim lstOfHighlightedString As List(Of String) = New List(Of String)()
    Try
    For Each EachRun In Docx.MainDocumentPart.Document.Body.Descendants(Of Run)()
    If EachRun.RunProperties IsNot Nothing Then
    For Each EachPrpChild In EachRun.RunProperties.ChildElements
    If TypeOf EachPrpChild Is Highlight Then
    Dim highlightVal As Highlight = TryCast(EachPrpChild, Highlight)
    If highlightVal.Val.Equals(HighlightColorValues.Yellow) Then
    lstOfHighlightedString.Add(EachRun.InnerText)
    End If
    End If
    Next EachPrpChild
    End If
    Next EachRun
    Catch e1 As Exception

    Throw
    End Try
    Return lstOfHighlightedString

Viewing 1 post (of 1 total)