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?
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
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 = 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.
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.