Sono stato con la macro riportata di seguito per estrarre gli elementi tra parentesi per i commenti in word:
'
' CommentBubble Macro
'
'
Dim myRange As Range
Set myRange = ActiveDocument.Content
searchtext = "\(*\)"
With myRange.Find
.MatchWildcards = True
Do While .Execute(findText:=searchtext, Forward:=True) = True
If Len(myRange.Text) > 4 Then
ActiveDocument.Comments.Add myRange, myRange.Text
myRange.Text = ""
End If
Loop
End With
End Sub
La ragione per cui la lunghezza del testo, > 4 è perché questi sono documenti legali e non voglio isolare le stringhe che sono cose come "con le seguenti condizioni: (i) la condizione 1, (ii) la condizione 2, etc."
Tuttavia, qui è un frammento di testo per i quali il codice di cui sopra si rompe:
This is sample text (with some additional text) that does stuff (with more stuff) and represents 39.4% of shares on the effective date (before giving effect, with some conditions such as ( some stuff (i) and some stuff (ii) with final stuff) and more final stuff) which is subject to (some conditions here) and conclude here.
Se si esegue questa si ottiene il seguente risultato:
This is sample text that does stuff and represents 39.4% of shares on the effective date and some stuff (ii) with final stuff) and more final stuff) which is subject to and conclude here.
Come si può vedere la parentesi nidificate causare alcuni problemi. Qualche consiglio?
Grazie!