We have found that with some older Windows ODBC drivers, it is necessary to specify the driver explicitly in the AMPL "table" statement. To find the name of your Excel ODBC driver, go to
Control Panel / Administrative Tools / ODBC Data Sources (64-bit)
(if you are running 64-bit Excel; there are also 32-bit versions). Then find the name of the driver in the small window that appears:
Specify the driver and filename explicitly like this:
table vhtype IN "ODBC"
"Driver=Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb);DBQ=AutoProgramaDeVueloV4.xlsm":
vehicle <- [Vehicle], type;
However the driver name on your system may be different from the name shown above, and you will have to adjust the command accordingly. (It might be necessary to do this even though .xlsm is mentioned in the driver name.) If you continue to have trouble, a workaround is to save the file in .xlsb format instead.
We have observed that Excel doesn't expose dynamic ranges via ODBC. However a suggestion for an alternative is described in this comment: https://groups.google.com/d/msg/ampl/QS30gef2Hnk/lm90jq2KRdkJ.
Bob Fourer
am...@googlegroups.com