View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ted Ted is offline
external usenet poster
 
Posts: 48
Default Trouble exporting ado rs to Excel

Hi, I am having trouble as a newbee. I am trying to export the dataset to
excel spread sheet. But I am unsure what the recordset object is called in
..net. Here is what I have so far:
Private Sub ExportToExcel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ExportToExcel.Click
Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Dim ws As Microsoft.Office.Interop.Excel.Worksheet
Dim rng As Microsoft.Office.Interop.Excel.Range
Try
excel = New Microsoft.Office.Interop.Excel.Application
wb = excel.Workbooks.Add()
ws = wb.ActiveSheet()
ws.Range("A1").CopyFromRecordset

excel.Visible = True
wb.Activate()
'Catch ex As COMExceptionMessageBox.Show("Error accessing Excel:
" + ex.ToString())
'Catch ex As ExceptionMessageBox.Show("Error: " + ex.ToString())
Finally

End Try


End Sub

I appoligize but like I said I am new, Can anyone help me out. Thanks, Ted