What is the best way to check if object exists before using set on it ?
I have many workbooks, they contain checkboxes and optionbuttons. I have an array that contain the list of all possible names of checkboxes and optionbuttons that the different workbooks may have
to make my question clear, let us suppose that i have
sArray(i) = "CheckBox15"
when I do
Set s = .OLEObjects(sArray(i))
is giving me an error 1004 when there is no a checkbox called "CheckBox15" in the active sheet.
what I want in my below code, is to add a line that tells :
if "CheckBox15" exists on current sheet (ws) then set .... is there any command that check if an object exists ?
'ws is the worksheet
Dim s As OLEObject
Dim i As Long
with ws
For i = 0 To UBound(sArray)
Set s = .OLEObjects(sArray(i))
If s.Object.Value = True Then
GetOptionCheck = GetOptionCheck & s.Object.Caption
End If
Next i
end with