' ****************************************************************************** ' GetModelType - macro recorded on 11/27/01 by u.clemens ' ****************************************************************************** Dim swApp As Object Dim DrawingDoc As Object Dim ModelDoc As Object Dim ModelDocName As String Dim View As Object Dim errors As Long Const swDocPART = 1 Const swDocASSEMBLY = 2 Const swInvalidFileTypeError = 0 Sub main() Set swApp = CreateObject("SldWorks.Application") Set DrawingDoc = swApp.ActiveDoc Set View = DrawingDoc.GetFirstView 'erste Ansicht ist das Blatt ! Set View = View.GetNextView 'jetzt die erste Ansicht ! ModelDocName = View.GetReferencedModelName swApp.SendMsgToUser (ModelDocName) Set ModelDoc = swApp.OpenDoc2(ModelDocName, swDocASSEMBLY, True, True, True, errors) If errors = swInvalidFileTypeError Then Set ModelDoc = swApp.OpenDoc2(ModelDocName, swDocPART, True, True, True, errors) If ModelDoc.gettype = swDocASSEMBLY Then swApp.SendMsgToUser ("das ist eine Baugruppe") If ModelDoc.gettype = swDocPART Then swApp.SendMsgToUser ("das ist ein Teil") End Sub