checkbox value on Workbook_Open

I have a checkbox on my worksheet, that I would like to check the value of it when the workbook opens. Simple example would be:

If the user saved the workbook with the checkbox checked, then when he opens the workbook again, then cell A1 = 1, else A1 = 2.

I cannot figure out how to obtain the properties of this control (or any other toolbox control) from the Workbook_Open event. I am using Excel 2002 (10.4302.4219 SP2).

Any help will be greatly appreciated.

Mike



Answer this question

checkbox value on Workbook_Open

  • SR20

    Oh, you can identify the control by name. Just something like:

    If o.Object.Name="CheckBox1" Then ...



  • Anthony McGary

    How do I indentify a specific control

    This is what I have: 2 combo boxes that have their ListFillRange populate data from 2 other worksheets in this workbook. Then the LinkedCell is used by a VLookup to display information on the worksheet. The combo boxes always displays the first record in the worksheet, so to avoid user errors, I added code to Workbook_Open to give the worksheet cells that is used by the VLookup a value of "". Then they are able to select values from the combo boxes that will alter those cells via the LinkCell property. But I want to give the user an option to keep the value they choose in the combo box. Hence the checkbox... one for each combo box.


  • Belal Jan

    Here you go.

    Option Explicit

    Private Sub Workbook_Open()
    Dim ws As Worksheet, o As OLEObject
    Set ws = Me.Worksheets("Sheet1")
    For Each o In ws.OLEObjects
    If o.Object.Value Then MsgBox "Box is checked!" Else MsgBox "Box is not checked!"
    Next o
    End Sub



  • checkbox value on Workbook_Open