i am trying to get this code to work and can't figure out why i get the error Next without For. any help would be helpful.
Dim swApp As SldWorks.SldWorks
Dim Part As ModelDoc2
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim colDrawing As Collection
Dim EXL As Excel.Application
Dim drawExlSheet As Excel.Worksheet
Dim tempWbook As Workbook
Sub main()
Set colDrawing = New Collection
Set EXL = GetObject(, "Excel.Application")
Set tempWbook = EXL.ActiveWorkbook
'MsgBox tempWbook.Name
Set drawExlSheet = tempWbook.ActiveSheet
Set swApp = Application.SldWorks
Dim fileLocation As String
Dim fileName As String
Dim fileType As String
Dim fileConfig As String
Dim savePath As String
'savePath = "U:\Desktop\test folder for macros"
Dim i As Integer
'rows 2 to 100
For i = 2 To 5
fileLocation = drawExlSheet.Range("B" & i).Value
fileName = drawExlSheet.Range("C" & i).Value
fileConfig = drawExlSheet.Range("D" & i).Value
fileType = drawExlSheet.Range("E" & i).Value
If fileType = "" Then
Next i
End If
If fileName <> "" Then
Set Part = swApp.NewDocument("Q:\Product Development\Common Parts\SOLIDWORKS TEMPLATES\Drawing.slddrt", 10, 0.594, 0.841)
'swApp.ActivateDoc2 "Draw1 - Sheet2", False, longstatus
Set Part = swApp.ActiveDoc
longstatus = Part.SaveAs(fileLocation & fileName & ".SLDDRW")
colDrawing.Add Part, fileName & ".SLDDRW" '???
' MsgBox fileName & ".SLDDRW"
End If
Next i
'activate the required drawing file and add code to update the drawing file
Dim tempModelDoc As ModelDoc2
Set tempModelDoc = colDrawing("ABC-26.SLDDRW")
swApp.ActivateDoc tempModelDoc.GetTitle()
swApp.CloseDoc tempModelDoc.GetTitle()
End Sub
SolidworksApi/macros