I want to extract a part file name from an assembly by clicking the part in the assembly tree
I have recorded a macro, but I am not sure how to get the extract file name from the macro. Please see the attachment
I want to extract a part file name from an assembly by clicking the part in the assembly tree
I have recorded a macro, but I am not sure how to get the extract file name from the macro. Please see the attachment
Try these codes
Option Explicit Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swSelMgr As SelectionMgr Dim selComp As Component2 Dim sPath As String Sub Main() Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swSelMgr = swModel.SelectionManager Set selComp = swSelMgr.GetSelectedObjectsComponent4(1, -1) sPath = Strings.Mid(selComp.GetPathName, InStrRev(selComp.GetPathName, "\") + 1) sPath = Left(sPath, InStrRev(sPath, ".") - 1) MsgBox sPath End Sub
Try these codes