Attribute VB_Name = "starNOTE01" Option Explicit Declare PtrSafe Function SetWindowPos Lib "user32" _ (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, _ ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long Public Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Public res As Long Public lRet As Long Global Const SWP_NOMOVE As Long = 2 Global Const SWP_NOSIZE As Long = 1 Global Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE Global Const HWND_TOPMOST As Long = -1 Global Const HWND_NOTOPMOST As Long = -2 Sub main() Dim swApplication As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swDrawing As SldWorks.DrawingDoc Dim swSelectionManager As SldWorks.SelectionMgr Dim swFeature As SldWorks.Feature Dim swNote As SldWorks.Note Dim swAnnotation As SldWorks.Annotation Dim makroPfad As String Dim dateiName As String Dim returnValue As Long Dim selectedObject As Object Dim attachPosition As Variant Dim attachedEntities As Variant ' Applikation festlegen Set swApplication = Application.SldWorks ' Makropfad ermitteln makroPfad = swApplication.GetCurrentMacroPathFolder + "\" Debug.Print "Makropfad: ", makroPfad ' prüfen, ob Dokument geöffnet ist If swApplication.ActiveDoc Is Nothing Then returnValue = swApplication.SendMsgToUser2("Kein Dokument geöffnet! Das Makro wird beendet.", swMbWarning, swMbOk) Exit Sub End If ' Dateinamen ermitteln dateiName = swApplication.ActiveDoc.GetPathName Debug.Print "Dateiname: ", dateiName ' prüfen, welche Art von Dokument aktiv ist If swApplication.ActiveDoc.GetType = swDocASSEMBLY Then Debug.Print "Aktuelle Datei ist eine Baugruppe." Debug.Print "Makro wird beendet." Exit Sub End If If swApplication.ActiveDoc.GetType = swDocDRAWING Then Debug.Print "Aktuelle Datei ist eine Zeichnung." Set swDrawing = swApplication.ActiveDoc End If If swApplication.ActiveDoc.GetType = swDocPART Then Debug.Print "Aktuelle Datei ist ein Part." Debug.Print "Makro wird beendet." Exit Sub End If ' ausgewähltes Element untersuchen Set swSelectionManager = swApplication.ActiveDoc.SelectionManager If swSelectionManager.GetSelectedObjectType2(1) = 15 Then ' eine Note ist selektiert Debug.Print "Es ist eine Note selektiert." Set swNote = swSelectionManager.GetSelectedObject6(1, 0) Debug.Print "Note.GetName(): " & swNote.GetName Debug.Print "Note.GetText(): " & swNote.GetText Debug.Print "Note.IsAttached(): " & swNote.IsAttached attachPosition = swNote.GetAttachPos() Debug.Print "Note-Andockposition: " & attachPosition(0) & " / " & attachPosition(1) & " / " & attachPosition(2) ' zugehoerige Annotation Set swAnnotation = swNote.GetAnnotation Debug.Print "Annotation.GetName(): " & swAnnotation.GetName Debug.Print "Annotation.GetType(): " & swAnnotation.GetType Debug.Print "Annotation.GetAttachedEntityCount3(): " & swAnnotation.GetAttachedEntityCount3 ' angedockte Elemente erfassen attachedEntities = swAnnotation.GetAttachedEntities3 End If End Sub