I have this piece of code that works at home, see at the level of your boolstatus line, in the first part. I don't understand the "/"... Aren't you editing a component?
Edit: You must have: "Configuration@nomfichier.extension"
Dim Part As Object Dim boolstatus As Boolean Dim longstatus As Long, longwarnings As Long
Dim swApp As SldWorks.SldWorks Dim swAssy As SldWorks.assemblyDoc Sun swSelMgr As SldWorks.selectionMgr Dim swModel As SldWorks.ModelDoc Dim swComp As SldWorks.Component Dim ConfigMgr As ConfigurationManager Dim instance As ISelectionMgr Dim Index As Integer Dim Mark As Integer Dim boolstatus As Boolean Dim modelDoc2 As SldWorks.modelDoc2 Dim assemblyDoc As SldWorks.assemblyDoc Dim featureMgr As SldWorks.FeatureManager Dim modelDocExt As SldWorks.ModelDocExtension Sun selectionMgr As SldWorks.selectionMgr Dim feature As SldWorks.feature Dim selObj As Object Dim feat As SldWorks.feature Dim folderFeat As SldWorks.feature Dim errors As Long Dim warnings As Long Dim status As Long Dim count As Long Dim Value As SldWorks.Component2 Dim componentsToMove() As Object Sun i As Long Dim retVal As Boolean Dim RefCfg As String
Sub main()
Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swAssy = swModel Set swSelMgr = swModel.SelectionManager Set ConfigMgr = swModel.ConfigurationManager Set modelDoc2 = swApp.ActiveDoc Set assemblyDoc = modelDoc2
'Select component Set modelDocExt = modelDoc2.Extension Set selectionMgr = modelDoc2.SelectionManager status = modelDocExt.SelectByID2("testEUT15B0178'015 S-E SUPPORT CYLINDER-1@Assemblage1/testO-RING STD-2@testEUT15B0178'015 S-E SUPPORT CYLINDER", "COMPONENT", 0, 0, 0, True, 0, Nothing, 0) Set selObj = selectionMgr.GetSelectedObject6(1, -1) Set Value = selectionMgr.GetSelectedObjectsComponent4(1, -1)
' Show Config1 and make it the active configuration Value.ReferencedConfiguration = "O-RING Ø24xØ1.5"
It's almost that but it doesn't call for the right configuration...
Set swApp = CreateObject("SldWorks.Application") Set Part = swApp.ActiveDoc
Set swApp = _ Application.SldWorks
Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swModelDocExt = swModel.Extension Set swSelMgr = swModel.SelectionManager
Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swAssy = swModel Set swSelMgr = swModel.SelectionManager Set ConfigMgr = swModel.ConfigurationManager Set ModelDoc2 = swApp.ActiveDoc Set AssemblyDoc = ModelDoc2
'Select component Set modelDocExt = ModelDoc2.Extension Set SelectionMgr = ModelDoc2.SelectionManager Status = modelDocExt.SelectByID2("CleanSeal COMPLETE-1@Assemblage1/Cxxx-x-2@CleanSeal COMPLETE", "COMPONENT", 0, 0, 0, True, 0, Nothing, 0) Set selObj = SelectionMgr.GetSelectedObject6(1, -1) Set Value = SelectionMgr.GetSelectedObjectsComponent4(1, -1)
' Show Config1 and make it the active configuration Value.ReferencedConfiguration = "Cxxx-x C250-0"