Get All Notes Example in Drawing Template (VBA)
This example shows how to get all of the notes in a drawing template.
'---------------------------------------------
'
' Preconditions: Drawing document is open.
'
' Postconditions: All notes in the drawing template are
selected.
'
'----------------------------------------------
Option Explicit
Sub main()
Dim
swApp As
SldWorks.SldWorks
Dim
swModel As
SldWorks.ModelDoc2
Dim
swDraw As
SldWorks.DrawingDoc
Dim
swView As
SldWorks.View
Dim
swNote As
SldWorks.note
Dim
swAnn As
SldWorks.Annotation
Dim
bRet As
Boolean
Set
swApp = CreateObject("SldWorks.Application")
Set
swModel = swApp.ActiveDoc
Set
swDraw = swModel
Set
swView = swDraw.GetFirstView '
This is the drawing template
Set
swNote = swView.GetFirstNote
swModel.ClearSelection2 (True)
Debug.Print
"File = " & swModel.GetPathName
Do
While Not swNote Is Nothing
Set
swAnn = swNote.GetAnnotation
bRet
= swAnn.Select2(True, 0)
Debug.Assert
bRet
Debug.Print
" "
& swNote.GetName
Debug.Print
" "
& swNote.GetText
Set
swNote = swNote.GetNext
Loop
End Sub
'---------------------------------------------