Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
ActiveSheet.QueryTables.Add using a File DSN
I have the following subroutine that runs on the activation of several
different worksheets in different workbooks. I would like to be able to just reference the DSN file for login information rather than explicitly set the server, username, and password in every single workbook and worksheet. It would make it much easier to distribute the workbook to several different users if all they had to do is edit one file with a text editor. Private Sub Worksheet_Activate() Sheet3.Activate Columns("A:D").Select Selection.ClearContents useDate = Range("H35").Value With ActiveSheet.QueryTables.Add(Connection:= _ "ODBC;DRIVER=SQL Server;SERVER=SQL_SERVER_1;UID=username;PWD=passwo rd;APP=Microsoft Office XP" _ , Destination:=Range("A1")) .CommandText = Array("exec stored_proc") .Name = "TESTQUERY" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlOverwriteCells .SavePassword = True .SaveData = False .AdjustColumnWidth = True .RefreshPeriod = 0 .PreserveColumnInfo = True .Refresh BackgroundQuery:=False End With End Sub How would I set it up so that it would connect to the database just by referencing the file at "C:\Program Files\Common Files\ODBC\Data Sources\testquery.dsn"? Thank you for any help. Brian |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
ActiveSheet.QueryTables.Add using a File DSN
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
With ActiveSheet.QueryTables.Add | Excel Programming | |||
QueryTables Interrupt if URL is Down | Excel Programming | |||
ActiveSheet.Name? | Excel Programming | |||
ActiveSheet | Excel Programming |