Jump to content
Sign in to follow this  
joeloyzaga

combobox input fromexcel

Recommended Posts

joeloyzaga

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
Authenticity

#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
joeloyzaga

#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
Authenticity

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
joeloyzaga

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
Authenticity

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  

×