I know I am a bit of a newbe but here it is. The purpose is to get reference numbers for sheet metal parts and show the thickness and material, qty and so on. The code works fine in 32 bit. In 64 bit it will bring up the first sheet metal part in the parts list ok and then on next it shows the second one and freezes and then crashes IV09. I have a column in the parts list for the file path. If this is still not enough please give me an email so I can send files for full functionality.
Private Sub GetSheetMetal()
Dim oDocNum, ProjNum, ItemNum, ItemFilePath As String
If a <> 0 And b <> 0 And c <> 0 Then
' Iterate through the contents of the parts list.
NextRow:
' Get the current row.
ItemFilePath = ""
Set oRow = oPartList.PartsListRows.Item(f)
oRowVis = oRow.Visible
If oRowVis Then
' If row is visible and is sheet metal then get file path
If oRow.Item(c).Value = "Sheet Metal" Then
ItemFilePath = CStr(oRow.Item(b).Value)
If ItemFilePath <> "" Then
' Get the sheet metal component definition. Because this is a part document whose
' sub type is sheet metal, the document will return a SheetMetalComponentDefinition
' instead of a PartComponentDefinition.
Dim oSheetMetalCompDef As SheetMetalComponentDefinition
ProjNum = oDrawDoc.PropertySets.Item("Design Tracking Properties").Item("PROJECT").Value
ItemNum = CStr(oRow.Item(a).Value)
oDocNum = oDrawDoc.PropertySets.Item("User Defined Properties").Item("Document number").Value
Set oModel = ThisApplication.Documents.Open(ItemFilePath, False)
Set oSheetMetalCompDef = oModel.ComponentDefinition
TextBox1.Value = CStr(oRow.Item(a).Value)
TextBox2.Value = oModel.DisplayName
TextBox3.Value = CStr(oRow.Item(d).Value)
TextBox4.Value = CStr(ProjNum & oDocNum & "-" & ItemNum)
TextBox5.Value = CStr(oSheetMetalCompDef.ActiveSheetMetalStyle.Material.Name _
& " " & oSheetMetalCompDef.ActiveSheetMetalStyle.Thickness)
f = f + 1
oModel.Close (False)
Set oSheetMetalCompDef = Nothing
Set oModel = Nothing
Exit Sub
Else
MsgBox ("File Path Not Present - Check Parts List Type")
f = f + 1
Exit Sub
End If
Else
f = f + 1
If f <= i Then
GoTo NextRow
Else
cmdOk.Enabled = False
Exit Sub
End If
End If
Else
f = f + 1
If f <= i Then
GoTo NextRow
Else
cmdOk.Enabled = False
Exit Sub
End If
End If
Else
MsgBox ("Check Parts List Type")
Exit Sub
End If
End Sub