1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
Set wb = Workbooks.Open("C:\Documents and Settings\29 12 2011.xls", True, True)
' open the source workbook, read only
'
With ActiveSheet.QueryTables.Add(Connection:=Array( _
"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=C:\Documents and Settings\mohammed.zniber\Bureau\test\Cop" _
, _
"ie de opérations oblig cdg et cdg cap du 29 12 2011.xls;Mode=Share Deny Write;Extended Properties=""HDR=YES;"";Jet OLEDB:System da" _
, _
"tabase="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=35;Jet OLEDB:Database Locking Mode=0;J" _
, _
"et OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create Syst" _
, _
"em Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replic" _
, "a Repair=False;Jet OLEDB:SFP=False"), Destination:=Range("A2"))
.CommandType = xlCmdTable
.CommandText = Array("'repo cdg k$'")
.Name = "Copie de opérations oblig cdg et cdg cap du 29 12 2011"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = _
"C:\Documents and Settings\29 12 2011.xls"
.Refresh BackgroundQuery:=False
End With
wb.Close False ' close the source workbook without saving any changes
Set wb = Nothing ' free memory
Application.ScreenUpdating = True ' turn on the screen updating |
Partager