Automation error creating OLE objects

J

Jean Leblanc

I created a series of macros using VBA to help manipulate
data in Excel 2002 with SP2. In one of the sheets I
create check boxes on each line for users to select or
deselect data. For an unknown reason after creating 1208
check boxes the execution stops with:

Run-time error '-2147319765(8002802b)'
Automation error
Element not found

It seems that the 1209th check box is not created. Does
anyone know if there is some kind of limitation on this?
or am I doing something wrong?

Here is the code:

Function Mark()
mCount = 0
Worksheets(mName).Activate
Do While mCount < mLastRow - 2
If mNum = 0 Then
Set OLEo = ActiveSheet.OLEObjects.Add
ClassType:="Forms.CheckBox.1", Link:=False, _
DisplayAsIcon:=False, Left:=590, Top:=25,
Width:=12, Height:=12)
With OLEo
.PrintObject = False
.Top = 24.75 + mCount * 12.75
.Name = "RerunBox" + Format(mCount + 1, "0")
End With
End If
Range(Cells(3 + mCount, 12), Cells(3 + mCount,
12)).Select
If Selection.Value = "NA" Then Range(Cells(3 +
mCount, 6), Cells(3 + mCount, 7)).Font.Bold = True
If Selection.Value >= 25 And Selection.Value <> "NA"
Then
Selection.Font.ColorIndex = 3
If mNum = 0 Then OLEo_Object.Value = True
End If
If Selection.Value >= 15 And Selection.Value < 25
Then Selection.Font.ColorIndex = 5
mCount = mCount + 1
Set OLEo = Nothing
Loop
Range("A1").Select
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top