By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,208 Members | 1,456 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,208 IT Pros & Developers. It's quick & easy.

Vb code for Exporting Access table to Excel

P: 21
Hello All,
I'm looking for the vb code that export an access table to specific worksheet in Excel. I tried to search see if this question was answered before here, but didn't find anything that really relates to this question.

I will appreciate your help,

thanks in advance.
Aug 20 '10 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 15k+
P: 31,761

We don't generally work that way. We are happy to help you, and lead you to a certain extent, but we draw the line at simply providing boiler-plate code on request.

If you would like to share what you've already tried and possibly ask a specific question related to where you're stuck then we can help further.

I can tell you that using the following requires the table or QueryDef object being exported to have the same name as the worksheet you want to export it into :
Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferSpreadsheet()
The TableName parameter would be the important one here.
Aug 20 '10 #2

P: 21
Thanks Neopa,

Yes I'm using DoCmd.TransferSpreadsheet() .Sorry I wasn't so clear in my question. My problem was when using TransferSpreadsheet() after I open up the excel file I get error message because of the file type. The code I was using is:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "TABLE NAME", "FILE PATH", True, "WorkSheet Name"
After I did a little bit of search , I figured I have to change acSpreadsheetTypeExcel12 to acSpreadsheetTypeExcel12Xml to create *.xlsx file type.

Thanks for your reply,
Aug 20 '10 #3

Expert Mod 15k+
P: 31,761
Good work Sarah :)

I'm still using 2003 so know very little about 2007 specific facilities, as this would seem to be.
Aug 20 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.