output the result to EXCEL

  • Thread starter Thread starter James
  • Start date Start date
J

James

I added a cmd button in a form that when I click on it, it
runs a stored procedure that uses ActiveX EXE method to
copy a recordset of a query result to an Excel file. What
I need to do is the following:-
after the recordset of the query is copied to the Excel
file, I want to copy the recordset of another query to the
same Excel file and the same workbook. I don't want the
second recordset to overwrite the first recordset from the
first query. I want it to be copied after the last row of
data from the first recordset. What is the code to use for
this?

Hope this wasn't to confusing.

Thanks
 
I added a cmd button in a form that when I click on it, it
runs a stored procedure that uses ActiveX EXE method to

I want it to be copied after the last row of
data from the first recordset. What is the code to use for
this?

Rather depends on the syntax and usage of the ActiveX thing you are using.
Can you ask the original programmer, or is it a commercial one?

B Wishes


Tim F
 
James, use the CurrentRegion command to accomplish this. This method
recognizes the boundary edges of the selected recordset.

e.g.:

Dim objXL As Excel.Application
Dim objWB As Excel.Workbook
Dim objRange As Excel.Range
Dim intCountRows As Integer

Set objXL = New Excel.Application
Set objWB = objXL.Workbooks.Open("C:\Workbook.xls")

objXL.Visible = True

Set objRange = objWB.Worksheets(1).Range("A1").CurrentRegion 'Presume that
Cell A1 is the first cell with the data from recordset 1 !
objRange.Select

intCountRows = objRange.Rows.Count + 2 'add 2 rows for new insert of
recordset

'Start here your CopyFromRecordset with the new location in intCountRows as
your new row heading
' End of
Code------------------------------------------------------------------------
 
Thank you Arjan. The CurrentRegion command worked well
-----Original Message-----
James, use the CurrentRegion command to accomplish this. This method
recognizes the boundary edges of the selected recordset.

e.g.:

Dim objXL As Excel.Application
Dim objWB As Excel.Workbook
Dim objRange As Excel.Range
Dim intCountRows As Integer

Set objXL = New Excel.Application
Set objWB = objXL.Workbooks.Open("C:\Workbook.xls")

objXL.Visible = True

Set objRange = objWB.Worksheets(1).Range
("A1").CurrentRegion 'Presume that
 
Back
Top