Sign in to follow this  
Followers 0
blumi

Excel Form Elements & AutoIt

4 posts in this topic

Hi,

I open an Excel Sheet an insert some values with AutoIt.

In the Excel file are some checkboxes.

Is there a way with AutoIt to check/uncheck these elements?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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  

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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
Sign in to follow this  
Followers 0