He estado usando la siguiente macro para sacar los elementos entre paréntesis a los comentarios en la palabra:
'
' 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 razón por la que tengo la longitud del texto > 4 es debido a que estos son documentos legales y no quiero aislar las cadenas que tienen cosas como "en las siguientes condiciones: (i) la condición 1, (ii) la condición 2, etc".
Sin embargo, aquí es un fragmento de texto para que el código anterior se 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.
Si ejecuta este obtendrá el siguiente resultado:
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.
Como se puede ver el paréntesis anidados causar algunos problemas. Algún consejo?
Gracias!