Hi,

for a number of a circumstances I am trying to read from excel files as if they are databases to use the recordset in a VBA macro.
it all goes nice and well, but I cannot use fieldnames on my query, I have to use SELECT * FROM ...
and then use fieldIndex when extracting information with getRows(fields:=fA) where fA is a field index array

I have tried puting names in brackets [], forward ticks, `` and nothing at all but nothing seems to work.


 Const COMMENTARIOc As Integer = 7
        
        Set COMMwb = openWorkbook(sFile:=COMMwb_PATH)
        
        With COMMcn
            .Provider = "Microsoft.ACE.OLEDB.12.0"
            .ConnectionString = "Data Source=" & COMMwb.fullname & ";Extended Properties=""Excel 12.0;HDR=Yes;"""
            .Open
        End With
        
        
        sqlAdd = getSQLaddress(rg:=COMMwb.Worksheets("Comentarios").Range("Tabla_Comentarios[#ALL]"))
        sqlStr = "SELECT * FROM " & sqlAdd & " AS T"
        Set COMMrs = New ADODB.Recordset
    
        COMMrs.Open Source:=sqlStr, _
                ActiveConnection:=COMMcn, _
                LockType:=adLockReadOnly
                
        fA = Array(COMMENTARIOc)
    
    
        commDataA = COMMrs.GetRows(Fields:=fA)
however, I do have managed to use field names in queries of querytables
but have no idea how to achieve the same in code

with the macro recorder I did get something as follows

    With ActiveWorkbook.Connections("2016-11-22_Standbuch_Gültig_SE27X_1").OLEDBConnection
        .BackgroundQuery = True
        .CommandText = Array("SELECT [Zona],[Descripción] FROM [STB_DATA$]")
        .CommandType = xlCmdSql
        .Connection = Array("OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=\\Vfesseatmare\ep\Compartida\EP-TOOL\03_PROYECTOS\ProyectosPiezasStandbuch\01_DESARROLLO\01_FUENTES\02_Macro Standbuch\Macro Modificada\STANDBUCH\SE27X\MUESTRA DESARROLLO\2016-11-22_Standbuch_Gültig_SE27X_.xlsm;Mode=Share Deny Write;Extended Properties=""HDR=YES;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet " _
                            , "OLEDB:Engine Type=37;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;" _
                            , "Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy " _
                            , "Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False;" _
                            , "Jet OLEDB:Bypass UserInfo Validation=False")
        .RefreshOnFileOpen = False
        .SavePassword = False
        .SourceConnectionFile = ""
        .SourceDataFile = "\\Vfesseatmare\ep\Compartida\EP-TOOL\03_PROYECTOS\ProyectosPiezasStandbuch\01_DESARROLLO\01_FUENTES\02_Macro Standbuch\Macro Modificada\STANDBUCH\SE27X\MUESTRA DESARROLLO\2016-11-22_Standbuch_Gültig_SE27X_.xlsm"
        .ServerCredentialsMethod = xlCredentialsMethodIntegrated
        .AlwaysUseConnectionFile = False
        .ServerFillColor = False
        .ServerFontStyle = False
        .ServerNumberFormat = False
        .ServerTextColor = False
    End With
Anyone can iluminate me?
Thank you!