Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use VBA to export query to Excel file

Status
Not open for further replies.

LaCour

MIS
Jul 15, 2004
53
US
Is it possible to use VBA to export a query to an Excel file?

Is it possible to use VBA to update and existing Excel file?


Thanks
Blair
 
Have a look at the TransferSpreadsheet method in Access help.

-Gary
 
Blair,

I usually prefer to set up a query IN EXCEL to Access that updates whenever the workbook opens. NO CODE REQUIRED.

Skip,

[red]Be advised:[/red] [glasses]
Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue]
 
Question 1: Yes - code follows.
'------------------------------------------------------------
' ExportToExcel
'
'------------------------------------------------------------
Function ExportToExcel()
On Error GoTo ExportToExcel_Err

DoCmd.OutputTo acTable, "Table2", "MicrosoftExcelBiff8(*.xls)", "c:\test.xls", False, "", 0


ExportToExcel_Exit:
Exit Function

ExportToExcel_Err:
MsgBox Error$
Resume ExportToExcel_Exit

End Function

Question 2: Probably, but easiest way to manipulate excel data from access is to link to the spreadsheet as a linked table, then create update query or vba code to update.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top