joeloyzaga Posted March 21, 2009 Posted March 21, 2009 Anybody know how to set up a combobox items from cells in an excel worksheet?
Authenticity Posted March 21, 2009 Posted March 21, 2009 #include <Excel.au3> Dim $sPath = @ScriptDir & '\Test1.xls' Dim $oExcel = _ExcelBookOpen($sPath, 0) Dim $aArray = _ExcelReadSheetToArray($oExcel) _ExcelBookClose($oExcel, 0) Dim $sStr = '' For $i = 1 To $aArray[0][0] For $j = 1 To $aArray[0][1] If $aArray[$i][$j] <> "" Then $sStr &= $aArray[$i][$j] & '|' Next Next $sStr = StringTrimRight($sStr, 1) GUICreate('Title', 170, 23) GUICtrlCreateCombo('', 0, 0, 170, 23) GUICtrlSetData(-1, $sStr) GUISetState() Do Sleep(20) Until GUIGetMsg() = -3 Exit
joeloyzaga Posted March 21, 2009 Author Posted March 21, 2009 (edited) #include <Excel.au3> Dim $sPath = @ScriptDir & '\Test1.xls' Dim $oExcel = _ExcelBookOpen($sPath, 0) Dim $aArray = _ExcelReadSheetToArray($oExcel) _ExcelBookClose($oExcel, 0) Dim $sStr = '' For $i = 1 To $aArray[0][0] For $j = 1 To $aArray[0][1] If $aArray[$i][$j] <> "" Then $sStr &= $aArray[$i][$j] & '|' Next Next $sStr = StringTrimRight($sStr, 1) GUICreate('Title', 170, 23) GUICtrlCreateCombo('', 0, 0, 170, 23) GUICtrlSetData(-1, $sStr) GUISetState() [color="#FF0000"][u]$aaa = GUIGetMsg() MsgBox(0, "a", $aaa)[/u][/color] Do Sleep(20) Until GUIGetMsg() = -3 ExitI just added above - why do I get $aaa = -11? Edited March 21, 2009 by joeloyzaga
Authenticity Posted March 21, 2009 Posted March 21, 2009 Include the library: #include <GuiConstantsEx.au3> -11 is posted because of $GUI_EVENT_MOUSEMOVE event. If you don't feel confident with AutoIt yet it'd be a good start to start with a few tutorials like AutoIt-1-2-3 or the examples in the AutoIt installation directory.
joeloyzaga Posted March 23, 2009 Author Posted March 23, 2009 Include the library:#include <GuiConstantsEx.au3>-11 is posted because of $GUI_EVENT_MOUSEMOVE event. If you don't feel confident with AutoIt yet it'd be a good start to start with a few tutorials like AutoIt-1-2-3 or the examples in the AutoIt installation directory.This puts all colums within all rows - what about All Rows, Col1 only?
Authenticity Posted March 23, 2009 Posted March 23, 2009 Read about the _ExcelReadSheetToArray in the help file, you can specify what row or column to start with and how much rows or columns to read.
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