Jump to content

Recommended Posts

Posted

I'm new to Autoit but learning fast.

I writing a script to extract cells from a number of Excel spreadsheets and write them to a "summary" spreadsheet.

It all works fine except that one of the items I need is the contents of a dropdown box. I realise that this is an object, not a cell, but I'm not too clear how to read the contents.

Any help would be appreciated.

Posted

Try this:

$oExcel=_ExcelBookAttach("c:\SS1.xls")
ConsoleWrite($oExcel.Application.ActiveSheet.DropDowns("Drop Down 171").Value &@CRLF)

You will receive the index number of the selected dropdown value. - For Example if "Tender" is selected you will receive 2

as it is the second value from the list , and you will receive 4 if "Inverse Auction" is selected.

Posted

It's the box for "Bids received by".

These are Drop Down controls. It would have been a lot easier to convert all to Validation drop downs

and then read from the cell directly. However if you insist in using as is try the following:

#include <Excel.au3>
$oExcel = _ExcelBookOpen(@DesktopDir & "\test2.xls", 1)
With $oExcel.ActiveSheet.DropDowns("Drop Down 171")
    $Selected = .List(.ListIndex)
EndWith
MsgBox(0, '', $Selected)
Posted (edited)

I have no control over the format of the spreadsheet.

Both solutions work fine.

Thanks for everyones help.

Edited by Saintsfan
  • 1 month later...
Posted (edited)

If it is a basic dropdown box - most likely "Data Validation - List" it should be easily read as a normal Cell:

msgbox(0,"",$oExcel.Range("B5").Value)

Hi Juvigy, but how could you actually read all the values in this list? Your example would only give you the top(visible) entry. Edited by CHAFF
Posted

I am guessing you speak of a DataValidation List ?

It is a list to a range of cells.Here is an example:

With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="=$L$8:$L$12"
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
    End With

As you can see , the values are located : - "$L$8:$L$12"

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
×
×
  • Create New...