Need to edge out the competition for your dream job? Train for certifications today.
Dim rs As dao.Recordset
Dim xlObj As Object, Sheet As Object, iCol As Integer
Set xlObj = CreateObject("Excel.Application")
Set rs = CurrentDb.OpenRecordset("query1")
Set Sheet = xlObj.ActiveWorkbook.Worksheets("Sheet1")
'clear contents of sheet1
For iCol = 0 To rs.Fields.Count - 1
Sheet.Cells(1, iCol + 1).Value = rs.Fields(iCol).Name
Sheet.Range("A2").CopyFromRecordset rs 'copy the data
'save the excel file
Set Sheet = Nothing
Set xlObj = Nothing
Open in new window
This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.