Tenho vindo a utilizar a macro a seguir para retirar itens entre parênteses para comentários no 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
A razão de eu ter o comprimento do texto a ser > 4 é porque estes são documentos legais e eu não quero isolar seqüências de caracteres que tem coisas como "nas seguintes condições: (i) condição 1, (ii) condição 2, etc."
No entanto, aqui está um trecho do texto para que o código acima quebras de:
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 você executar isso, você vai obter o seguinte 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 você pode ver o parênteses aninhados causar alguns problemas. Algum conselho?
Obrigado!