Hope someone can help me with this.
I am looking for someone to modify a macro for me. I have a macro that I got of the net about 12 months ago that I am having a problem with. The problem is that towards the end of the code there is a comment that says the macro will remove any unused configs in a part when it is run but it doesn't seem to work. The macro when run saves each config as a new part in the same path with a new name (name is the config description). I really need these extra config to be stripped from each new part as the file sizes just get to big to handle. Any help would be great as I don't have any idea of coding what so ever.
----------------------------------------------------------------------------
--------------- Option Explicit Sub main() Dim swApp As SldWorks.SldWorks Set swApp = Application.SldWorks Dim swModel As SldWorks.ModelDoc2 Set swModel = swApp.ActiveDoc Dim swConfig As SldWorks.configuration Set swConfig = swModel.GetActiveConfiguration Dim fname, ext, current As String fname = swModel.GetPathName ext = Mid(fname, InStr(fname, ".")) ' extension with leading dot fname = Mid(fname, 1, InStr(fname, ".") - 1) ' path + name without extension current = swModel.GetActiveConfiguration.name Dim configs As Variant configs = swModel.GetConfigurationNames Dim i As Long For i = 0 To UBound(configs) If Not swModel.ShowConfiguration2(configs(i)) Then Debug.Print ("Could not switch to config " + configs(i)) Else Dim name As String name = fname + configs(i) + ext Dim err As Long Dim warning As Long Call swModel.SaveAs4(name, swSaveAsCurrentVersion, _ swSaveAsOptions_Copy + swSaveAsOptions_Silent + swSaveAsOptions_AvoidRebuildOnSave, _ err, warning) Dim newdoc As SldWorks.ModelDoc2 Set newdoc = swApp.OpenDoc(name, swDocPART) ' works only for parts at the moment If Not (newdoc Is Nothing) Then ' let's remove the unneeded configs Dim j As Long For j = 0 To UBound(configs) If (i j) Then newdoc.DeleteConfiguration (configs(j)) Next j swApp.CloseDoc (name) End If End If Next i swModel.ShowConfiguration2 (current) ' revert to current config End Sub
----------------------------------------------------------------------------
----------------------- Cheers Damian