I have a problem I have got stuck on.
I want to export my Access table to an Excel file. Currently, I do that using DoCmd.TransferSpreadsheet, but I wa
This Excel macro retrieves data from your MS Access database:
Sub Makro1()
''
Const sDB = "c:\db1.mdb"
Const sSQL = "SELECT * FROM Table1"
With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;DSN=MS Access-database;DBQ=" + sDB + ";FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;" _
, Destination:=Range("A1"))
.CommandText = Array(sSQL)
.Name = "Query1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
End Sub