Hi people,
I use the following code to import data from an access table in to excel. However database is password protected. I have added the password in to the code below on numerous lines but whenever I run the macro the password box pops up. When I enter the password the macro runs fine but what am I missing? This should work without the password box popping up but I really can not see why it does not automatically enter.
I have posted this on another forum but with no luck. Any help is appreciated.
Sub Macro1()
With ActiveSheet.QueryTables.Add(Connection:=Array( _
"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password=""bullseye"";Data Source=\\Dfz70588\106124001\workgroup\IPC CMT\AccuracyMonitoringApplication\AccuracyMonitoring.mdb;Mode=Share Deny Write" _
, _
";Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password=""bullseye"";Jet OLEDB:Engine " _
, _
"Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New " _
, _
"Database Password=""bullseye"";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Comp" _
, "act=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False" _
), Destination:=Range("A1"))
.CommandType = xlCmdTable
.CommandText = Array("tblError") 'table to import
.Name = "AccuracyMonitoring" 'name of query
.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 = "\\Dfz70588\106124001\workgroup\IPC CMT\AccuracyMonitoringApplication\AccuracyMonitoring.mdb"
.Refresh BackgroundQuery:=False
End With
End Sub
Bookmarks