You can implement very complex tool with selection events and preview graphics, but this is not for beginners.
You can use this simple macro which utilizes built-in command for creation of LeaderNotes. You create empty LeaderNotes and when you finish the command, appropriate values will be set automatically. You can run this rule multiple times and the index will continue.
Create LeaderNotes rule
Dim sharedVariableName As String = "W_index"
Dim drw As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = drw.ActiveSheet
Dim leaderNotes As LeaderNotes = sheet.DrawingNotes.LeaderNotes
'Setup index
Dim wIndex As Integer = 1
If SharedVariable.Exists(sharedVariableName) Then
wIndex = SharedVariable(sharedVariableName)
End If
'Get count of LeaderNotes before start command
Dim countBefore As Integer = leaderNotes.Count
'Start command
'Don't put any text, when you are prompted and
'continue with Ctrl+Enter keyboard shortcut and
'create as many notes as you want
ThisApplication.CommandManager.ControlDefinitions("DrawingLeaderTextCmd").Execute2(True)
'Get count of LeaderNotes after command terminates
Dim countAfter As Integer = leaderNotes.Count
'Set text to currently created LeaderNotes
'previously inserted text will be overwritten
For i As Integer = countBefore + 1 To countAfter
leaderNotes(i).Text = "W" & wIndex
wIndex = wIndex + 1
Next
'Store last index for future use
SharedVariable(sharedVariableName) = wIndex
If you want to set new index value, you can use this rule
Dim sharedVariableName As String = "W_index"
'Setup index
Dim wIndex As Integer = 1
If SharedVariable.Exists(sharedVariableName) Then
wIndex = SharedVariable(sharedVariableName)
End If
'Input new value
Dim newIndex = InputBox("Set new index", "W index", wIndex)
wIndex = Integer.Parse(newIndex)
'Store last index for future use
SharedVariable(sharedVariableName) = wIndex