SpiritOfLennon
IS-IT--Management
Hi,
I've written a subroutine in a module that generates Excel output. I can pass a SQL string to it and run the query to populate the spreadsheet, however this seems inefficient as I'm already running the query to populate a flexgrid. So I tried to set it up so that I could just pass it the recordset. Here's what I have..
Private Sub Command2_Click()
MousePointer = 11
Excel_Export (rs1)
MousePointer = 1
End Sub
The subroutine I have defined is like this
Public Sub Excel_Export(rs As ADODB.Recordset)
Dim xlApp As excel.Application
Dim xlBook As excel.Workbook
Dim xlSheet As excel.Worksheet
Dim vcnt As Integer
Dim vcol_num As Integer
Dim Vrng_end As String
Dim Vrng_end2 As String
'Run_Query (strSQL)
If rs.RecordCount > 0 Then
Set xlApp = CreateObject("Excel.Application"
Set xlBook = xlApp.Workbooks.Add
etc...
When I hit the button I get
Run-Time error 13
type mismatch
Any ideas?
SOL
I'm only guessing but my guess work generally works for me.
I've written a subroutine in a module that generates Excel output. I can pass a SQL string to it and run the query to populate the spreadsheet, however this seems inefficient as I'm already running the query to populate a flexgrid. So I tried to set it up so that I could just pass it the recordset. Here's what I have..
Private Sub Command2_Click()
MousePointer = 11
Excel_Export (rs1)
MousePointer = 1
End Sub
The subroutine I have defined is like this
Public Sub Excel_Export(rs As ADODB.Recordset)
Dim xlApp As excel.Application
Dim xlBook As excel.Workbook
Dim xlSheet As excel.Worksheet
Dim vcnt As Integer
Dim vcol_num As Integer
Dim Vrng_end As String
Dim Vrng_end2 As String
'Run_Query (strSQL)
If rs.RecordCount > 0 Then
Set xlApp = CreateObject("Excel.Application"
Set xlBook = xlApp.Workbooks.Add
etc...
When I hit the button I get
Run-Time error 13
type mismatch
Any ideas?
SOL
I'm only guessing but my guess work generally works for me.