Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Assigning click event to OleObjects checkbox

Dear group

How is it possible to assign a click event to a checkbox that has been placed within a worksheet using the following code..

Dim OleObjectsObject As OLEObject
Dim OleControl As OLEObjec
Dim CheckBox As MSForms.CheckBo

Set OleControl = OleObjectsObject.Add(ClassType:="Forms.CheckBox.1"
Set CheckBox = ExcelWorkSheet.OLEObjects(OleControl.Name).Objec

Best regards

Jim...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Assigning click event to OleObjects checkbox

Hi Jim

Here is a example for a button
You can adapt it for a checkbox

Sub test()
Dim WS As Worksheet
Dim Btn As OLEObject
Set WS = ThisWorkbook.Worksheets("Sheet1")
With WS
Set Btn = .OLEObjects.Add(ClassType:="Forms.CommandButton.1" , _
Left:=.Range("C3").Left, Top:=.Range("C3").Top, _
Width:=100, Height:=30)
End With
Btn.Object.Caption = "Click Me"
Btn.Name = "TheButton"
With ThisWorkbook.VBProject.VBComponents(WS.CodeName).C odeModule
.InsertLines .CreateEventProc("Click", Btn.Name) + 1, _
"Msgbox ""Hi there"" "
End With
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Jim McLeod" wrote in message ...
Dear group,

How is it possible to assign a click event to a checkbox that has been placed within a worksheet using the following code...

Dim OleObjectsObject As OLEObjects
Dim OleControl As OLEObject
Dim CheckBox As MSForms.CheckBox

Set OleControl = OleObjectsObject.Add(ClassType:="Forms.CheckBox.1" )
Set CheckBox = ExcelWorkSheet.OLEObjects(OleControl.Name).Object

Best regards,

Jim...



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Assigning click event to OleObjects checkbox

An example of more complex code than Ron shows would be

With ThisWorkbook.VBProject.VBComponents(WS.CodeName).C odeModule
.InsertLines .CreateEventProc("Click", Btn.Name) + 1, _
vbTab & "If Range(""A1"").Value 0 Then " & vbCrLf & _
vbTab & vbTab & "Msgbox ""Hi""" & vbCrLf & _
vbTab & "End If"
End With

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ron de Bruin" wrote in message
...
Hi Jim

Here is a example for a button
You can adapt it for a checkbox

Sub test()
Dim WS As Worksheet
Dim Btn As OLEObject
Set WS = ThisWorkbook.Worksheets("Sheet1")
With WS
Set Btn = .OLEObjects.Add(ClassType:="Forms.CommandButton.1" , _
Left:=.Range("C3").Left, Top:=.Range("C3").Top, _
Width:=100, Height:=30)
End With
Btn.Object.Caption = "Click Me"
Btn.Name = "TheButton"
With ThisWorkbook.VBProject.VBComponents(WS.CodeName).C odeModule
.InsertLines .CreateEventProc("Click", Btn.Name) + 1, _
"Msgbox ""Hi there"" "
End With
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Jim McLeod" wrote in message

...
Dear group,

How is it possible to assign a click event to a checkbox that has been

placed within a worksheet using the following code...

Dim OleObjectsObject As OLEObjects
Dim OleControl As OLEObject
Dim CheckBox As MSForms.CheckBox

Set OleControl = OleObjectsObject.Add(ClassType:="Forms.CheckBox.1" )
Set CheckBox = ExcelWorkSheet.OLEObjects(OleControl.Name).Object

Best regards,

Jim...





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checkbox Event BHatMJ Excel Discussion (Misc queries) 2 May 16th 08 06:14 PM
Action Event, CheckBox, Add Row and Textbox Ryan Excel Discussion (Misc queries) 2 July 17th 07 02:32 PM
Click event for checkbox from Forms toolbar Carolyn Excel Discussion (Misc queries) 6 September 11th 06 08:16 PM
checkbox event handling function nevwalters Excel Worksheet Functions 2 May 16th 06 04:27 AM
CheckBox Event devin Excel Programming 2 January 29th 04 05:59 PM


All times are GMT +1. The time now is 03:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"