View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
James McDowell[_2_] James McDowell[_2_] is offline
external usenet poster
 
Posts: 29
Default Adding Embedded OLE Objects on a Spread Sheet

It tells me that my event handler is invalid.

"Bob Phillips" wrote:

Here is an example

Dim StartLine As Long

With ActiveWorkbook.VBProject.VBComponents("Sheet1").Co deModule
StartLine = .CreateEventProc("Click", "wkCheck1") + 1
.InsertLines StartLine, _
"Dim ans" & vbCrLf & _
" ans = Msgbox( ""All OK"",vbYesNo)" & vbCrLf & _
" If ans = vbNo Then MsgBox ans"
End With



--

HTH

RP
(remove nothere from the email address if mailing direct)


"James McDowell" <James wrote in message
...
Hey, this is my first posting so bear with me...
I have embedded several checkboxes on a spread sheet and i wish to write
code for the change event, but i can not figure how to get to it. I

created
the checkboxes through code:
MySheet.OLEObjects.Add ("Forms.CheckBox.1")

Set myOLEObject = MySheet.OLEObjects.Item(xx)

myOLEObject.Name = "wkCheck" & x

myOLEObject.Activate
myOLEObject.Left = ActiveCell.Left
myOLEObject.Top = ActiveCell.Top
myOLEObject.Height = ActiveCell.RowHeight
myOLEObject.Width = ActiveCell.Width
myOLEObject.Object.Caption = ""

How can i write into the VBA the change event code? I have played with

VBE
before, but am not too strong in that area.

Please help. I want to kick off a query when the check box is changed to
true.

Thank you,
James McDowell