I'm just upgraded to 2010 and one of my macros does not work any more. I have narrowed it down to a method that has been obsoleted but I can not get the new method to work. I'm sure I'm just missing some small detail but I can't see where it is. Below is my attempt at the new code, it is just an part of the code that seems to be having the problem. What it should do is open every part and subassembly being used in the current document and then save them to a directory defined by "BackUpPath". I set "BackUpPath" to a temp string for this code example.
Sub main()
Dim swApp2 As Object
Dim Part2 As Object
Dim errors As Long
Dim warnings As Long
Dim NDocs As Integer
Dim Docs As String
Dim i As Integer
Dim CurrentFile As String
Dim DepName As String
Dim ComponentName As String
Dim swApp As ISldWorks
BackUpPath = "C:\temp\"
NDocs = swApp.IGetDocumentDependenciesCount2(CurrentFile, True, True, False)
Docs = swApp.IGetDocumentDependencies2(CurrentFile, True, True, False)
Set part = swApp.IActiveDoc2
Set swApp2 = part
pagecount = swApp2.GetSheetCount
CurrentFile = part.GetPathName
If CurrentFile = "" Then
part.save3 swSaveAsOptions_Silent And swSaveAsOptions_Copy, errors, warnings
CurrentFile = part.GetPathName
End If
For i = 0 To (NDocs - 1) Step 2
MsgBox "NDocs =" + Str(NDocs) 'this line was added for debugging
DepName = Docs(i + 1)
MsgBox "Docs =" + Str(Docs) 'this line was added for debugging
test2 = Split(DepName, "\")
ComponentName = test2(UBound(test2))
MsgBox "Ready to save " + ComponentName 'this line was added for debugging
Set Part2 = swApp.ActivateDoc2(ComponentName, True, errors)
Set Part2 = swAppActiveDoc
Part2.SaveAs2 BackUpPath + ComponentName, 0, True, False
Next
End Sub
SolidworksApi macros