Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm using Execl 2000 and am trying to write a macro that will write query
results to a text file rather than return the results to an excel spreadhseet. Anyone know how to do this? Any help would be greatly appreciated! Here is the code I have now that returns the query results to a spreadsheet Sub refresh_plc() sql = "select max(day) from dataroom_plc_data " DoQuery ("D4") End Sub ----------- Sub DoQuery(dest As String) 'Create new query Range(dest).Select rindex = Selection.Row cindex = Selection.Column Dim connstr As String Dim rs As ADODB.Recordset Dim cmd As ADODB.Command Dim cn As ADODB.Connection connstr = "User ID=me;Password=pwd;Data Source=database;Provider=MSDAORA.1" Set cn = New ADODB.Connection Set rs = New ADODB.Recordset cn.Open (connstr) rs.Open sql, cn Cells(rindex, cindex).CopyFromRecordset rs End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Checkbox - Output results to a csv file | Excel Worksheet Functions | |||
output to the same line in a Text file? | Excel Discussion (Misc queries) | |||
Formatted output to text file | Excel Programming | |||
Open CSV file, format data and write output to a text file. | Excel Programming | |||
Output color to a text (rtf) file | Excel Programming |