Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Macro/change connection to SQL database

Status
Not open for further replies.

tadimil

Programmer
Aug 26, 2003
19
US
Below is code used in a macro in EXCEL. I need to change the connection to use a SQL table instead. It is currently using a database in Access 2000. All the data has been moved into a SQL database. The Database name/DSN is Lab. Thanks in advance for your help!

Sub Mud()
'
' Mud Macro

With ActiveSheet.QueryTables.Add(Connection:=Array( _
"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=S:\Lab\Morning Programs\MorningProgramTables.mdb;Mode=Sha" _
, _
"re Deny Write;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet " _
, _
"OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;J" _
, _
"et OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy L" _
, _
"ocale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False" _
), Destination:=Range("AH14"))
.CommandType = xlCmdTable
.CommandText = Array("MudForExcel")
.Name = "MorningProgramTables_1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = "S:\Lab\Morning Programs\MorningProgramTables.mdb"
.Refresh BackgroundQuery:=False
End With
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top