VBA to read text of RTF file

ROBERT CHEN

New Member
Joined
Dec 4, 2024
Messages
1
Office Version
  1. 2010
Platform
  1. Windows
Please kindly advise me the EXCEL VBA HOW TO Read an RTF file line by line without format code "only the text"?
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Rich text format (with formatting tags) in Excel to unformatted text

Another resource ... suggested macro from Jindon :

VBA Code:
Sub test()
    Dim a, i As Long, m As Object, temp As String
    With Range("a1").CurrentRegion
        a = .Value
        With CreateObject("VBScript.RegExp")
            .Global = True
            .Pattern = "{\S+ ([^};]+(?!\;))\}"
            For i = 1 To UBound(a, 1)
                temp = a(i, 1): a(i, 1) = Empty
                For Each m In .Execute(temp)
                    a(i, 1) = a(i, 1) & m.submatches(0)
                Next
            Next
        End With
        .Value = a
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,750
Messages
6,180,736
Members
452,995
Latest member
isldboy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top