Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
darren.lees
935 Views, 5 Replies

The dreaded - Object reference not set to an instance of an object

Hi All,

 

I have another, hopefully, eaay problem.

 

I wish to interrogate a parts list on a drawing.  Something I've done in the past.

 

However, this time I'm tring to populate an array with each of the values in the REVISION column.

I'll then figure out how to find the highest value character in the array and do some magic in the drawing based on that. 

 

My dilema is, when I try to add a value to the array inside a FOR LOOP, I get the dreaded "Object reference not set to an instance of an object" error and my limited knowledge of VB.NET can't sem to get past it.  It has to be an easy fix.

 

Code below.....

 

' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oPartList As PartsList
oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(1)

' Iterate through the contents of the parts list
Dim i As Long
Dim LetterArray() As String
For i = 1 To oPartList.PartsListRows.Count
	'look at only the REVISION column
	oCell = oPartList.PartsListRows.Item(i).Item("REVISION")
	
	'Test to see if we have the correct REVISION letter
	MessageBox.Show("Revision of item " & i & " is " & oCell.Value, "Revs")

	'Populate the array with the REVISION letter
	LetterArray(i) = oCell.Value
	'PRODUCES THIS - Object reference not set to an instance of an object
	'PLEASE HELP!!!   I don't ask for much.  I'm a good man.....really!!!
	'I pay my bills and taxes......etc!!
Next
	

 

 

Please help!!

This was easier when we just used BASIC as a language.  Who thought it was a good idea to invent different computer languages??  Sheesh!!! :rolling_on_the_floor_laughing:

 

 

 

Tags (1)