- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone
I have a question propose, I would like replace text of existing Leader Note with a new text through ilogic , but the code does not work, can someone help me find the error.
I want replace "P9" in "N9"
code :
If ThisApplication.ActiveDocumentType <> kDrawingDocumentObject Then
MessageBox.Show("This rule only works in a drawing document.", "Change Leader Text",MessageBoxButtons.OK,MessageBoxIcon.Error)
Return
End If
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
Dim oLeaderNote As LeaderNote
Dim TXT2Find As String
Dim NewTXT As String
saveOriginalText = False
addDescription = False
Question = MessageBox.Show("Overwrite existing leader text?", "Change Leader Text",MessageBoxButtons.YesNoCancel,MessageBoxIcon.Question,MessageBoxDefaultButton.Button1)
Select Case Question:
Case vbYes
saveOriginalText = False
Case vbNo
saveOriginalText = True
Case vbCancel
Return
End Select
oDescription = NewTXT
'get user input
TXT2Find = InputBox("Enter Text To Find:", "iLogic", "XXX")
'look for blank value
If TXT2Find ="" Then
Return 'exit rule
Else
'Continue rule
End If
NewTXT = InputBox("Enter Text To Replace '"& TXT2Find _
& "' with.", "iLogic", "****")
oSheets = oDoc.Sheets
For Each oSheet In oSheets
Try
oGeneralNotes = oSheet.DrawingNotes.GeneralNotes
'look at gerenal notes
For Each oGeneralNote In oGeneralNotes
If oGeneralNote.FormattedText = TXT2Find Then
oGeneralNote.FormattedText = NewTXT
Else
End If
Next
Catch
oLeaderNotes = oSheet.DrawingNotes.LeaderNotes
'look at gerenal notes
For Each oLeaderNote In oLeaderNotes
If oLeaderNote.FormattedText = TXT2Find Then
oLeaderNote.FormattedText = NewTXT
Else
End If
Next
End Try
Next
For Each oLeaderNote In oDoc.ActiveSheet.DrawingNotes
'saves the original text
originalText = oLeaderNote.FormattedText
oLeaderNote.FormattedText = oDescription
'adds original beginning to end of label text if applicable
If saveOriginalText = True Then
oLeaderNote.FormattedText = oLeaderNote.FormattedText & vbCr & originalText
End If
Next
Solved! Go to Solution.
Link copied