Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime Error 20

Status
Not open for further replies.

MatthewGB

Programmer
Oct 22, 2002
39
AU
I receive a Runtime Error 20 when I programmatically create OLEObjects in Excel2000. What also happens is that any userforms which are shown are hidden when the error occurs. Does anyone know what Runtime Error 20 is, and how to get around it?

Thanks
 
That's strange. Run-time error 20 is "resume without error", which has nothing to do with OLE Objects.
Can you post the code that's having the problem?
Rob
[flowerface]
 
Rob,

This is the section of code that I think may be causing the problem. What happens it that when this part of the code is run, two modeless userforms on the side of the spreadsheet get hidden.

This is only a portion of the total code, so it may be another section of the code which is causing the problems.

Private Sub OLECheckbox()
Dim r, n As Range
Dim j As Integer
Dim theLeft, theTop As Single

j = Me.OLEObjects.Count + 1
For Each n In r
If IsEmpty(n) = False Then
theLeft = ((n.Width / 2) + n.Left) - (n.ColumnWidth / 2)
theTop = ((n.Height / 2) + n.Top) - (n.RowHeight / 2)
Me.OLEObjects.Add "Forms.CheckBox.1", _
Left:=theLeft, Top:=theTop, Height:=15, Width:=11.25
Me.OLEObjects.Item(j).LinkedCell = n.Address
j = j + 1
Else
End If
Next
End Sub

As you mentioned before, the OLEObjects shouldnt be causing this type of problem. If you think it may be something else i can send the rest of the code to you.

Thanks for your help

Matt
 
Which line of code does the error occur on? What kind of module is the code part of (i.e., what does "me" refer to here)?
Rob
[flowerface]
 
Me. refers to the worksheet on which the OLEObjects are created. But the thing is, when the userform is closed down, there is no error message. The previous error message i mentioned was from a error in my error handling routine.

However, the userform still shuts down when this code is run, even though no error is returned.
 
Okay, so your code for the OLEObject creation is part of your worksheet code module (why?). Where does the code that "show"ed the modeless userforms reside? If I was troubleshooting this, I'd first try to nail down exactly where in the code the userforms disappear - probably using a few msgbox'es. Nothing about your code jumps out at me as troublesome.
Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top