Jump to content

Excel Form Elements & AutoIt


Recommended Posts

In the Excel file are some checkboxes.

In an user-form (made with VBA) or inserted from <Toolbar: Formular> ? Are different way to use them.

Edit:

If you have used with Toolbar you can do so:

$oExcel = ObjGet('', 'Excel.Application')

_SetCheckboxState($oExcel, 2)        ; set CheckBox 2 = TRUE
_SetCheckboxState($oExcel, 1, False) ; set CheckBox 1 = FALSE


Func _SetCheckboxState($oExcel, $iNumber, $bState=True)
    Local Const $xlOn = 1, $xlOff = -4146
    Local $iState = $xlOn
    If Not $bState Then $iState = $xlOff
    $oExcel.ActiveSheet.Shapes("Check Box " & $iNumber).Select
    $oExcel.Selection.Value = $iState
EndFunc

By using an form you has access to the control with: ..CheckBox1 = True/False

Edited by BugFix

Best Regards BugFix  

Link to comment
Share on other sites

In an user-form (made with VBA) or inserted from <Toolbar: Formular> ? Are different way to use them.

Edit:

If you have used with Toolbar you can do so:

$oExcel = ObjGet('', 'Excel.Application')

_SetCheckboxState($oExcel, 2)        ; set CheckBox 2 = TRUE
_SetCheckboxState($oExcel, 1, False) ; set CheckBox 1 = FALSE


Func _SetCheckboxState($oExcel, $iNumber, $bState=True)
    Local Const $xlOn = 1, $xlOff = -4146
    Local $iState = $xlOn
    If Not $bState Then $iState = $xlOff
    $oExcel.ActiveSheet.Shapes("Check Box " & $iNumber).Select
    $oExcel.Selection.Value = $iState
EndFunc

By using an form you has access to the control with: ..CheckBox1 = True/False

I'll have to check it out, don't know at the moment.

The Excel file was not created by me.

Thanks for help.

Link to comment
Share on other sites

The built in checkboxes are non VBA, they are from the Excel Form Tools.

Have tried to use your function.

When I click on a checkbox I get a Name displayed with a number.

Is this the number I have to use to check/uncheck the box?

I have german excel and checkboxes are named "Kontrollkästchen".

Do I have to change the "Check Box" it in your function or not?

$oExcel.ActiveSheet.Shapes("Check Box " & $iNumber).Select
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...