Sign in to follow this  
Followers 0
joeloyzaga

combobox input fromexcel

6 posts in this topic

Anybody know how to set up a combobox items from cells in an excel worksheet?

Share this post


Link to post
Share on other sites



#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

Share this post


Link to post
Share on other sites

#3 ·  Posted (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
Exit
I just added above - why do I get $aaa = -11? Edited by joeloyzaga

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

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