exporting to excel

C

Chris

I have create a form which runs a query on the click of
the button. i want to export the form to excel and then
perform a couple of task inside excel ( inset to rows and
insert some text, then save as a .csv) First is this
possible to do? I thought I had figured out how to
transfer the spreadsheet but I am getting hung up because
I want to create and excel file, not use an exisiting
one. The last issue is the deletion of the query. I
have my macro set up such that each time the query is run
a unquie name is given based on the inputs selected. I
don't want to keep the queries so how do I delete them?
Thanks for you help. Here is the code I am trying right
now to export
Dim xls As Object
Dim xlsName As String

xlsName = "C:\" & compound & " " & media & " " & d1
& "-" & d2 & ".xls"

DoCmd.TransferSpreadsheet acExport,
acSpreadsheetTypeExcel9, qryname, xlsName,
True, "Query1Sheet"
Set xls = CreateObject("Excel.Application")
xls.Workbooks.Open xlsName
xls.Visible = True

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top