micky500970
Programmer
Hi,
I am creating a program with VB6 and storing data in Access. I want to create an Excel instance from within VB and then populate it with the all data from my query. I have got so far with this and now very much stuck.
I would be gratefull if somebody could give me a bit of guidance so that I can get my head round this.
Thanks in advance
Private Sub CmdReport_Click()
Dim sSql As String
Dim i As Integer
sconnect = "provider=microsoft.jet.OLEDB.4.0;data source = c:\ado\db1.mdb"
sSql = "select * from qryfullreport"
Set cn = New Connection
cn.Open sconnect
Set rs = New Recordset
rs.CursorLocation = adUseClient
rs.Open sSql, cn, adOpenForwardOnly, adLockReadOnly
Dim oExcel As Excel.Application
Dim oWB As Excel.Workbook
Dim oWS As Excel.Worksheet
Set oExcel = New Excel.Application
oExcel.Visible = True
Set oWB = oExcel.Workbooks.Add
Set oWS = oWB.Worksheets("Sheet1")
End Sub
I am creating a program with VB6 and storing data in Access. I want to create an Excel instance from within VB and then populate it with the all data from my query. I have got so far with this and now very much stuck.
I would be gratefull if somebody could give me a bit of guidance so that I can get my head round this.
Thanks in advance
Private Sub CmdReport_Click()
Dim sSql As String
Dim i As Integer
sconnect = "provider=microsoft.jet.OLEDB.4.0;data source = c:\ado\db1.mdb"
sSql = "select * from qryfullreport"
Set cn = New Connection
cn.Open sconnect
Set rs = New Recordset
rs.CursorLocation = adUseClient
rs.Open sSql, cn, adOpenForwardOnly, adLockReadOnly
Dim oExcel As Excel.Application
Dim oWB As Excel.Workbook
Dim oWS As Excel.Worksheet
Set oExcel = New Excel.Application
oExcel.Visible = True
Set oWB = oExcel.Workbooks.Add
Set oWS = oWB.Worksheets("Sheet1")
End Sub