Get and Set Name of Note Example (VBA)
This example shows how to get the name of the selected note and change
its name.
'---------------------------------
'
' Precondition: Drawing document is open and a note is
selected.
'
' Postcondition: Name of the selected note is
' changed
to "@MYADDIN-ANN1"
'
'---------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDrawing As SldWorks.DrawingDoc
Dim swSelMgr As SldWorks.SelectionMgr
Dim swNote As SldWorks.Note
Dim swAnn As SldWorks.Annotation
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set swNote = swSelMgr.GetSelectedObject6(1,
0)
Set swAnn = swNote.GetAnnotation
MsgBox swAnn.GetName
' New name must
be unique
swAnn.SetName
"@MYADDIN-ANN1"
MsgBox swAnn.GetName
End Sub