CustomTable Error: COMException when trying to read cell value

CustomTable Error: COMException when trying to read cell value

Anonymous
Not applicable
417 Views
3 Replies
Message 1 of 4

CustomTable Error: COMException when trying to read cell value

Anonymous
Not applicable
Please take a look at the code.

It contains code to access the value of a CustomTable cell. However in some use cases a value is never set and therefore a COMException is thrown. The code handles it with an On Error Resume next but I was wondering if there is a better way to handle the error.

Thanks,
Nate

Private Sub UpdateRevTable(ByVal RevTable As CustomTable)
Dim RowCount As Integer = RevTable.Rows.Count
Dim LastRow As Row = RevTable.Rows.Item(RowCount)
Dim newRowContents(0 To 7) As String
Dim newRow As Row
On Error Resume Next

Me.m_ecoNumber = LastRow.Item(3).Value
If Me.m_ecoNumber Is Nothing Then
Me.m_ecoNumber = ""
End If

Me.m_effectivity = LastRow.Item(4).Value
If Me.m_effectivity Is Nothing Then
Me.m_effectivity = ""
End If

Me.m_ER = LastRow.Item(2).Value
If Me.m_ER Is Nothing Then
Me.m_ER = ""
End If

'Update Revision Table
newRowContents(0) = "-" 'Rev
newRowContents(1) = Me.m_ER 'ER
newRowContents(2) = Me.m_ecoNumber 'ECO
newRowContents(3) = Me.m_effectivity 'Effectivitiy
newRowContents(4) = "INITIAL RELEASE" 'Description
newRowContents(5) = Me.userName 'DRW
newRowContents(6) = "" 'CHK
newRowContents(7) = "" 'DATE

newRow = RevTable.Rows.Add(RowCount, False, newRowContents)

End Sub
0 Likes
418 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
I tried to reproduce this problem but I don't understand what you mean by a
"value is never set". Can you post a drawing that contains a table and a
complete program that demonstrates the problem?
--
Brian Ekins
Autodesk Inventor API
0 Likes
Message 3 of 4

Anonymous
Not applicable
The details of the error is shown below. When I said value not set I was assuming the error came from the cell value being null instead of an empty string. It was just an idea which doesn't have any basis for accuracy.

Do you want the program code or just the dll? The attached drawing demonstrates the behavior. I removed the model from the drawing to protect sensitive company material. After doing this I get an error in the same spot but the details are different. If you would like the original drawing let me know and I can email it directly to you. the error is raised from this line of code:

Me.m_ER = LastRow.Item(2).Value

Where LastRow is defined as
Dim LastRow As Row = RevTable.Rows.Item(RowCount)

As you can see from the attached drawing that cell does not contain any text.

System.Runtime.InteropServices.COMException occurred
ErrorCode=-2147467259
Message="Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))"
Source=""
StackTrace:
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor.Cell.get_Value()
at Peterson.CAD.InitialReleaseUtility.UpdateRevTable(CustomTable RevTable) in C:\Documents and Settings\nathan.anderson\My Documents\Visual Studio 2005\Projects\PPCUtilities\PPCDrawingUtilities\DrawingUtilities\InitialRelease.vb:line 209
0 Likes
Message 4 of 4

Anonymous
Not applicable
I can reproduce it now with this sample drawing. I think this is a problem
and filed a change request. It should be returning an empty string for
these cases. For now you'll need to error trap these and assume the cell is
empty in the case of an error.
--
Brian Ekins
Autodesk Inventor API
0 Likes