Użyłem następujące makro do pobierania elementów w nawiasach dla komentarzy do programu 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
Powodem, dla którego u mnie długość tekstu > 4, polega na tym, że są to dokumenty prawne, a ja nie chcę izolować wiersze, w których są takie rzeczy, jak "w następujących warunkach: (i) warunek 1, (ii) warunek 2 Itd.".
Jednak oto fragment tekstu, do którego powyższy kod zostanie przerwany:
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.
Jeśli można uruchomić, otrzymasz następujący wynik:
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.
Jak widać, zagnieżdżone nawiasy powodują pewne problemy. Jakieś porady?
Dziękuję!