S
SF
Hi,
I want to exprt my rst to an excel sheet, formatting the header but I am
stuck. The code is attached below and hope someone would help on this issue.
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
'Check if PNGO is not selected
If IsNull(Me.PNGO) Then
MsgBox "You must select a Partner before you can proceed..", vbOKOnly +
vbInformation, "PNGO not selected"
Me.PNGO.SetFocus
Exit Sub
End If
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("MOFMissingReport")
qdf.PARAMETERS("ID") = ID
Set rst = qdf.OpenRecordset(dbOpenDynaset, dbSeeChanges)
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.Worksheets(1).Cells("A3").CopyFromRecordset rst
SF
I want to exprt my rst to an excel sheet, formatting the header but I am
stuck. The code is attached below and hope someone would help on this issue.
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
'Check if PNGO is not selected
If IsNull(Me.PNGO) Then
MsgBox "You must select a Partner before you can proceed..", vbOKOnly +
vbInformation, "PNGO not selected"
Me.PNGO.SetFocus
Exit Sub
End If
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("MOFMissingReport")
qdf.PARAMETERS("ID") = ID
Set rst = qdf.OpenRecordset(dbOpenDynaset, dbSeeChanges)
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.Worksheets(1).Cells("A3").CopyFromRecordset rst
SF