code:
Sub Macro1()
With ActiveSheet.QueryTables.Add(Connection:=
Array(
Array(_ "ODBC;DSN=MS Access Database;DBQ=C:\PrgFls\MS\OFF\DBs\Liam.mdb;DefaultDir=C:\PrgFls\MS" _),
Array(_ "OFF\DBs;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;" _)
),
Destination:=Range("C1"))
.CommandText = Array( _"SELECT someThing FROM someTable WHERE someConstraint" _)
.Name = "MrSquidgee1"
.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
Sub Macro2()
With ActiveSheet.QueryTables.Add(Connection:=
Array(
Array(_ "ODBC;DBQ=C:\WhateverYourAccessDBIsCalled.mdb;DefaultDir=C:\PrgFl\OFF\DBs;" _),
Array(_
"Driver={Driver do Microsoft Access (*.mdb)};DriverId=25;FIL=MS Access;
MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;SafeTransa"
_),
Array("ctions=0;Threads=3;UID=admin;UserCommitSync=Yes;")
),
Destination:= _ Range("C1"))
.CommandText = Array(_"SELECT someThing FROM someTable WHERE someConstraint"_)
.Name = "MrSquidgee2"
.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