Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Trigger an event on Checkbox change


Thanks for the responses everyone, but now I have a whole new problem. I
have created a function that will allow me create a checkbox in any
given cell. Because I just found out that checking the checkbox will not
trigger the change event on the worksheet I will need to attach a
general macro to all the checkboxes I create that have a name that
begins with "labor". For some reason when I run this code I get a run
time error that says "Unable to set the OnAction property of the
OLEObject class". Am I missing something or is there a better way to do
this?

'This function will create a checkbox when given a cell range, name for
the check box
'and a cell to link the value to
Function Create_Checkbox(ByVal CurrCell As String, _
ByVal ListName As String, _
ByVal CellLink As String)

Dim Obj As Object
Dim CBox As Object
Dim OldZoom As Integer


OldZoom = ActiveWindow.zoom
ActiveWindow.zoom = 100

Set Obj = ActiveSheet.OLEObjects.Add(classtype:="Forms.Check Box.1", _
Left:=Range(CurrCell).Left + (Range(CurrCell).width / 2) -
6.5, _
Top:=Range(CurrCell).Top + (Range(CurrCell).height / 2) - 5,
_
width:=11, height:=11)

Set CBox = Obj.Object
CBox.Caption = ""

With Obj
.Name = ListName
.LinkedCell = CellLink
If Left(ListName, 5) = "labor" Then
.OnAction = "UpdateLabor"
End If
End With

If Range(CellLink).Value = Empty Then
Range(CellLink).Value = "FALSE"
End If
Range("ObjectCounter").Value = Range("ObjectCounter").Value + 1
ActiveWindow.zoom = OldZoom
End Function


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
Trigger Event on Format Change Zone[_3_] Excel Discussion (Misc queries) 4 August 25th 07 05:43 PM
Trigger an event on Checkbox change James[_28_] Excel Programming 2 September 1st 04 08:31 PM
Trigger Event Todd Huttenstine Excel Programming 2 July 14th 04 06:50 PM
Using a checkbox to trigger an email Chris Excel Programming 1 August 12th 03 11:00 PM


All times are GMT +1. The time now is 11:31 AM.

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

About Us

"It's about Microsoft Excel"