long story short I'm using a script that highlights words that use a certain format and then exporting them to excel. I can't seem to use Word's built in wildcard system to get the results I'm looking for (I'm not very familiar with it), but I am close!
I'm looking to extract definitions that fall in a certain format inline:
This is the sample text (the "sample") for you ("helpful person" or "HP") to use, this "should be" possible.
My string should capture sample, helpful person, and HP above (but not "should be"). Which is to say all text in quotes between parenthesis.
Currently I can manage to pull everything between smart or straight quotes with this:
(" & ChrW(8220) & ")(*)(" & ChrW(8221) & ")
[the char numbers are for angled quotes]
This of course returns strings that are in quotes even without those quotes being nested in parenthesis.
Can anyone get me on the right track? Thanks so much!
Note that the rest of the script is using MSwords wildcard system, not regex, so changing to regex is out :(.
The full script here just highlights the words that match the string:
Sub findfunction()
If (findHL(ActiveDocument.Content, "(" & ChrW(8220) & ")(*)(" & ChrW(8221) & ")")) = True Then _
MsgBox "Done", vbInformation + vbOKOnly, "Result"
End Sub
Function findHL(r As Range, s As String) As Boolean
Options.DefaultHighlightColorIndex = wdYellow
r.Find.Replacement.Highlight = True
r.Find.Execute FindText:=s, MatchWildcards:=True, _
Wrap:=wdFindContinue, Format:=True, _
replacewith:="", Replace:=wdReplaceAll
findHL = True
End Function
Thanks again.