...Ecco ora che sono a casa al pc...ho fatto una prova simile...così parliamo un po' di vero codice...
- Codice: Seleziona tutto
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=C:\Users\User\Desktop\Bilancio\Elabo" _
, _
"ratore Dati Bilancio.xlsm;Mode=Share Deny Write;Extended Properties=""HDR=YES;"";Jet OLEDB:System database="""";Jet OLEDB:Registry" _
, _
" Path="""";Jet OLEDB:Database Password="""";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" _
), Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("BILANCIO$")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = _
"C:\Users\User\Desktop\Bilancio\Elaboratore Dati Bilancio.xlsm"
.ListObject.DisplayName = "Tabella_Elaboratore_Dati_Bilancio"
.Refresh BackgroundQuery:=False
End With
se lo faccio così il codice funziona...
quello che voglio fare io è Sostituire nell'array il percorso scritto:
"C:\Users\User\Desktop\Bilancio\Elaboratore Dati Bilancio.xlsm"
...in una Variabile..PERCORSO...
ho provato a fare così:
- Codice: Seleziona tutto
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" & PERCORSO & ";Mode=Share Deny Write;Extended Properties=""HDR=YES;"";Jet OLEDB:System database="""";Jet OLEDB:Registry" _
, _
" Path="""";Jet OLEDB:Database Password="""";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" _
), Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("BILANCIO$")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = PERCORSO
.ListObject.DisplayName = "Tabella_Elaboratore_Dati_Bilancio"
.Refresh BackgroundQuery:=False
End With
...ma nulla da fare...non funziona....e non riesco a spiegarmelo...il problema sta forse nel fatto che le variabili hanno di default le virgolette e che quindi gli da fastidio all'Array...??? oppure sono le & commerciali a dargli noia ???
Credo che se non riuscite ad aiutarmi voi....la posso anche dare su....ho girato tutto il Web...e mi reputo capace di trovare le cose....ma a questa...pare non ci sia soluzione...
Attendo Speranzoso un vostro Intervento...Magari dai Miei Aiutanti di tanto tempo fa...Flash o Antony... ;o)))