Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
In
set chart = ActiveDocument.GetSheetObject(myString)
I want to check for errors, suppose the chart object doesn't exist. What does the chart return, i thought it would return null, but apparently "if not isnull(chart) then" doesn't work.
Can anybody tell me (in code) what the test for a chart object not being found is?
IsNull doesn't work, because VB Script is kind of funny about Nulls. VB Script has three types of Null (not counting the empty string), Null, Empty and Nothing. Nothing is for objects (you'll see objects set to Nothing when they are no longer needed in a sub).
Apparently, IsNothing isn't available, but here is a way to test for Nothing:
Sub Tester
set chart = ActiveDocument.GetSheetObject("CH9999")
If TypeName(chart) = "Nothing" Then
' The object is empty
End If
End Sub
IsNull doesn't work, because VB Script is kind of funny about Nulls. VB Script has three types of Null (not counting the empty string), Null, Empty and Nothing. Nothing is for objects (you'll see objects set to Nothing when they are no longer needed in a sub).
Apparently, IsNothing isn't available, but here is a way to test for Nothing:
Sub Tester
set chart = ActiveDocument.GetSheetObject("CH9999")
If TypeName(chart) = "Nothing" Then
' The object is empty
End If
End Sub