Files
Traverse all open documents
Code
'This code activates all open documents.
'Preconditions: SolidWorks is open
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim vDocs As Variant
Dim i As Integer
Sub main()
Set swApp = Application.SldWorks
vDocs = swApp.GetDocuments
For i = 0 To UBound(vDocs)
Set swModel = vDocs(i)
swApp.ActivateDoc3 swModel.GetTitle, False, swDontRebuildActiveDoc, Empty
Next i
End Sub
'Note that this code assumes that windows folder options are set to display the file _
extension of known file types, otherwise ISldWorks::ActivateDoc3 will get the first _
doc it finds with the specificed name. This could cause problems if a part and assy _
have the same name, for example.
'Note that if the second argument is set to true then the activated document will rebuild _
according to the option set in the Miscellaneous system option "swRebuildOnActivation", _
which does NOT show in the system options. It must be accessed through the API. If the _
second argument is false, the document rebuilds according to the third argument.