View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default how to execute a macro assigned to a checkbox in vba

Just a question/comment...

Things like this always scare me a little:

Set myCBX = SeriesWorkbook.ActiveSheet.CheckBoxes(CheckBoxName )

How do you know for sure what the activesheet in that workbook is?

If possible, I like to specify that sheet by name:

Set myCBX _
= SeriesWorkbook.Worksheets("sheetnamehere").CheckBo xes(CheckBoxName)




wrote:

Dave,

thanks for your help, i managed to achieve what i wanted to do with
your help.

for future reference:
now that i worked out how to do it i can also explain better what i
want to do:-)

i want to execute a macro assigned to a checkbox in vba, while in the
code all i have is the name of the checkbox, my final code looks like
this:

dim myCBX as checkbox
dim checkBoxAction as String

Set myCBX = seriesWorkbook.ActiveSheet.CheckBoxes( checkBoxName)
checkBoxAction = myCBX.OnAction
If "" < checkBoxAction Then
Run checkBoxAction
End If

before i had allready tried:
Run myCBX.OnAction
in analogy to a button control, but that doesn't work.

thanks again for your help,

Pieter


--

Dave Peterson