Code:
Set swapp = Application.SldWorks
Set swAllDocs = swapp.EnumDocuments2
Set FirstDoc = swapp.ActiveDoc DocCount = 0
swAllDocs.Reset
swAllDocs.Next 1, swdoc, NumDocsReturned
' This loop will go through all of the documents within an assembly, including sub-assemblies.
While NumDocsReturned <> 0
bDocWasVisible = swdoc.Visible ' Use Hidden Parts
' check the file to make sure it's a "sldprt" file.
If (UCase(Right(swdoc.GetPathName, 6)) = UCase("sldprt")) Then
swapp.ActivateDoc2 swdoc.GetPathName, True, longstatus 'open and activate the part
'Hier deinen Code reinfummeln
swdoc.SaveAs (swdoc.GetPathName) ' save the change
swapp.CloseDoc (swdoc.GetTitle()) ' close the part
End If
swAllDocs.Next 1, swdoc, NumDocsReturned ' Go to the next part
DocCount = DocCount + 1 ' Keep a count of all parts within the assembly, including sub-assemblies.
Wend