Hi
You might have to upload the files so we can test it and debug it.
I don't know everything about step 2 but if:
1) You want to run it automatically then you can change refresh values to do it automatically (the link can be set up manually)
2) If you want to run it manually then your code is fine and if you upload the files I can look into it, although I would normally create a recordeset using adodb and use range("A5").CopyFromRecord
Regards
Emil
Main Topics
Browse All Topics





by: JCJGPosted on 2009-11-04 at 16:44:22ID: 25745792
This is the codes I used for Step (2). I don't know how to write it so I just recorded it.
d(SourceTy pe:=0, Source:=Array( _ ACE.OLEDB. 12.0;Passw ord="""";U ser ID=Admin;Data Source=C:\My Documents\Work\test.accdb" _ ).QueryTab le llings")
Sub Data_Retrieve()
With ActiveSheet.ListObjects.Ad
"OLEDB;Provider=Microsoft.
, _
";Mode=Share Deny Write;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLE" _
, _
"DB:Database Password="""";Jet OLEDB:Engine Type=6;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"), Destination:=Range("$A$5")
.CommandType = xlCmdTable
.CommandText = Array("tbl_01-01_Output_Bi
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = _
"C:\My Documents\Work\test.accdb"
.ListObject.DisplayName = "Table_test.accdb"
.Refresh BackgroundQuery:=False
End With
End Sub