Hello,
I'm trying to search a custom table and output the values using a for loop. I'm having trouble accessing the cells in the column I want though. The problem child seems to be Line 18. Any help would be appreciated.
' Set a reference to the drawing document. ' This assumes a drawing document is active. Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument Dim sheet1 as Sheet = oDrawDoc.Sheets("Sheet:1") Dim table As CustomTable = sheet1.CustomTables.Item(1) MessageBox.Show("0", "Title") ' Iterate through the contents of the parts list. Dim i As Long For i = 1 To table.Rows.Count MessageBox.Show(i, "Title") 'look at only the DWG NO. column oCell = table.Rows.Item(i).Item("DWG NO.") MessageBox.Show(oCell, "Title") Next
Solved! Go to Solution.
Solved by gadurai. Go to Solution.
Hi,
.
I think you are missing the declaration for Ocell. In your code declare the following
Dim oCell As Cell
'look at only the DWG NO. column oCell = table.Rows.Item(i).Item("DWG NO.")
Messagebox.Show(oCell.Value,"Title").
The Following is my VBA code for your reference.
*****
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
Dim sheet1 As Sheet
Set sheet1 = oDrawDoc.Sheets("Sheet:1")
Dim table As CustomTable
Set table = sheet1.CustomTables.Item(1)
' Iterate through the contents of the parts list.
Dim i As Long
For i = 1 To table.Rows.Count
Dim oCell As Cell
'look at only the DWG NO. column
Set oCell = table.Rows.Item(i)(2)
Debug.Print (oCell.Value)
Next
End Sub
********
Regards,
Appadurai.G