I have an excel macro that runs a query off a table in an access db.
I am calling it from Access in a function. That works fine, the only thing is I get a prompt
asking me if U want to connect to the database. I need this to run automatically.
If I click "Yes", I get the data link properties pop up which I have to click OK, then I get
the OLE DB Initialization pop up and click ok again. Then the query runs and fills the spreadsheet with the fields.
How can I suppress these pop ups.
Thanks....Here is the macro that runs in Excel.
Sub Get_Combined_Quality_Tracker()
'
' Get_Combined_Quality_Tracker Macro
'
'
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=S:\Global Metrics\Work In Progress\Global Metrics - Qual" _
, _
"ity.mdb;Mode=Share Deny Write;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDBatabase " _
, _
"Password="""";Jet OLEDB:Engine Type=5;Jet OLEDBatabase 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 OL" _
, _
"EDBon't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Comp" _
, "lex Data=False"), Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("Combined Quality Tracker")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = _
"S:\Global Metrics\Work In Progress\Global Metrics - Quality.mdb"
.ListObject.DisplayName = "Table_Global_Metrics___Quality"
.Refresh BackgroundQuery:=False
End With
ActiveWorkbook.Save
End Sub
I am calling it from Access in a function. That works fine, the only thing is I get a prompt
asking me if U want to connect to the database. I need this to run automatically.
If I click "Yes", I get the data link properties pop up which I have to click OK, then I get
the OLE DB Initialization pop up and click ok again. Then the query runs and fills the spreadsheet with the fields.
How can I suppress these pop ups.
Thanks....Here is the macro that runs in Excel.
Sub Get_Combined_Quality_Tracker()
'
' Get_Combined_Quality_Tracker Macro
'
'
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=S:\Global Metrics\Work In Progress\Global Metrics - Qual" _
, _
"ity.mdb;Mode=Share Deny Write;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDBatabase " _
, _
"Password="""";Jet OLEDB:Engine Type=5;Jet OLEDBatabase 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 OL" _
, _
"EDBon't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Comp" _
, "lex Data=False"), Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("Combined Quality Tracker")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = _
"S:\Global Metrics\Work In Progress\Global Metrics - Quality.mdb"
.ListObject.DisplayName = "Table_Global_Metrics___Quality"
.Refresh BackgroundQuery:=False
End With
ActiveWorkbook.Save
End Sub