Bol som pomocou nasledujúceho makra vytiahnuť položky v zátvorkách na komentáre v programe 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
Dôvod, prečo som dĺžky textu sa > 4 je, pretože tieto sú právne dokumenty a nechcem, aby sa izolovať reťazce, ktoré majú veci, ako je "v nasledujúcich podmienkach: (i) podmienka 1, (ii) stav 2, atď."
Avšak, tu je úryvok textu, pre ktoré vyššie kód prestávky:
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.
Ak spustíte tento získate nasledujúci výsledok:
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.
Ako môžete vidieť na vnorených zátvoriek spôsobiť nejaké problémy. Nejaké rady?
Vďaka!