VBA RegExp CODE 5019

PauloCastelo

New Member
Joined
Jul 7, 2016
Messages
14
Hi folks,

It's my first time here and I'm needing your help.
I'm trying to use a specific regular expression, but when a I try execute, the message shows "Run-time error 5019"
The regular expression I'm using is "(Sumário\n[^]+)".
I done some tests and the error is "^".
How can I done it?

' Execução da Expressão regular
Dim posString As String
Dim newRegEx, newMatch, newMatches
Set newRegEx = New RegExp
newRegEx.pattern = "(Sumario\n[^]+)"


newRegEx.MultiLine = True
newRegEx.IgnoreCase = True
newRegEx.Global = True

Set newMatches = newRegEx.Execute(strTemp)

For Each newMatch In newMatches
RetStr = newMatch.Value
Next
strTemp = RetStr

My idea is take only expressions after word "Sumario".
I used a Macro to take Word Documment to insert in the string (strTemp)
When I tried used newRegEx.pattern = "(Sumario\n[]+)", it's done, but it's not works.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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