blumi Posted July 13, 2010 Share Posted July 13, 2010 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? Link to comment Share on other sites More sharing options...
BugFix Posted July 13, 2010 Share Posted July 13, 2010 (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 July 13, 2010 by BugFix Best Regards BugFix Link to comment Share on other sites More sharing options...
blumi Posted July 13, 2010 Author Share Posted July 13, 2010 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 More sharing options...
blumi Posted July 14, 2010 Author Share Posted July 14, 2010 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now