Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() hey guys, i found the solution by playing around with some stuff i found on Microsoft's site: Code: -------------------- Public Sub return_data() ' Declare the QueryTable object Dim qt As QueryTable ' Set up the SQL Statement sqlstring = "select * from test" ' Set up the connection string, reference an ODBC connection ' There are several ways to do this ' Leave the name and password blank for NT authentication connstring = _ "ODBC;Driver={SQL Server};Server=(local);UID=;PWD=;Database=test" ' Now implement the connection, run the query, and add ' the results to the spreadsheet starting at row A1 With ActiveSheet.QueryTables.Add(Connection:=connstring , Destination:=Range("A1"), Sql:=sqlstring) .Refresh End With End Sub -------------------- works a treat! ed -- edfollett ------------------------------------------------------------------------ edfollett's Profile: http://www.excelforum.com/member.php...o&userid=36227 View this thread: http://www.excelforum.com/showthread...hreadid=560157 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
always recheck data connection library for latest connection strin | Excel Discussion (Misc queries) | |||
no DDE connection?? | Excel Discussion (Misc queries) | |||
ADO Connection | Excel Programming | |||
mass data retreival from excel book in different folders | Excel Programming | |||
Auto Refreshing: data retreival from webpage | Excel Programming |