Full Version: Exporting a table to excel ....
UtterAccess Discussion Forums > Microsoft® Access > Access Automation
hokie1
I have a table called "Employees" ....

I want to export (using VBA code) this table. as is, to a Spreadsheet (Not existing) to be called newemps.xls

I want to retain the table field names as column headings in the SS ...

to folder C:\Testing

Can someone give me help with the code to do this?


Also, does the SS have to exist before this export can be done..?

TIA
pbaldy
Look at TransferSpreadsheet in VBA help.
vieirasoft
Look, try this:

Open the form in view and put an image or label with this..."Export to Excel"

You must create a QUERY from the table and not export the table

Create a Folder Named DOCS in the same folder of your MDB

Then on the Click Event:

On Error Resume Next
Dim Msg, Style, Title
Msg = "This function create an Excel file at Your Folder Name" & Chr(13) & Chr(10) & "You whish to continue?"
Style = vbYesNo
Title = "Export"
Msg = MsgBox(Msg, Style, Title)
If Msg = vbYes Then
DoCmd.OutputTo acQuery, "Your Query Name", "MicrosoftExcelBiff8(*.xls)",
"C:\Testing \Docs\YourQueryName.xls", False, "", 0
Else
End
End If

Feel free to ask me any question

sergiovieirasoft@gmail.com
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.