Read A Word Doc with Lines

Hi Guys,

I’m trying to get text from a word doc.

The whole doc is formatted in a table with lines.

I have managed to use matches to find what I’ve needed so far, but now I need a line of text but can’t seem to Split the string.

So I have Read Text of the docx and output is a wordstr.


I am trying to pull out “CELEBRATE THE WEEKEND WITH A WINNING OFFER!” But this text could vary.

I have tried splitting after "Name and before “Subtitle” ; Split(out_Brief, “Promotion Name”)(1)

But I can’t grab all of the text. I have checked the output in the log message and the string at this stage is “\r\a\r\aCELEBRATE THE WEEKEND WITH A WINNING OFFER!\r\a\r\a”

I have tried to split then further, but these characters from the lines in the doc prevent this from working…

Any help would be great, thanks!

Does YourText.Replace("\r\a\r\a","") works for you?

Hey man - no; I’ve tried that too…

I have tried both but the output is different in the output pane and the variable:

I’m not entirely sure which is exactly the one…

Hi, i dont seem to follow exactly what the problem is, do you have a sample word doc for us to try?

Test.docx (25.6 KB)

Here a sample; there are some dropdowns with content which are likely causing complications.


HI @Kyleb91
Have you tried using Match with Regex ?


I have tried, and use it successfully to grab other data on the Test doc I hae attached above, but can’t seem to grab that particular bit of text…

If you can user
Regex then apply below code:

Regex.Match(yourVariblehavingTableDataInString,"(?<=Promotion Name)[\s\S]*(?=Subtitle)").Value

Please see if this helps you:
textFromDocx=textFromDocx.Replace(Chr(7),"").Split(vbCr.ToCharArray, StringSplitOptions.RemoveEmptyEntries)


yes, i did in parallel

Brilliant @bcorrea ; not 100% sure how it works but it does :smiley:

1 Like

Hi @bcorrea I was hoping I could get some further help from you… thanks again for Friday’s help!

Test.docx (26.9 KB)

This is another edited doc, and what I am trying to do is check the contents under the Additional Tags? Sections

What I’m trying to do is if there is text in here, grab the string, and add this to a variable and use in a selector. There may be one word here, or multiple though…

I can’t seem to grab just the 'onboarding, prc" text, and I’m not sure how to separate by the comma, if there is a comma there (because there may only be one word here) and then ‘for each’ through the text received for use later.

Any help would be great!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.