Link to home
Start Free TrialLog in
Avatar of Tom_wbi
Tom_wbi

asked on

Access 2007 - Exporting TAble Contents to Excel 2007 Spreadsheet

Hi All,

I have seen this question posed all over online and yet none of the answers that seems to work for others actually works for me!  What I am trying to do is EXPORT the contents of an Acees 2007 Table to an Excel 2007 spreadsheet in XSLX format.

I have tried:

DoCmd.TransferText acExport, acSpreadsheetTypeExcel12Xml, "JournalRequest", "H:\WBC\Projects-in-Progress\Trade Preparation Database Tool\JournalRequest.xslx", True

and

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "JournalRequest", "H:\WBC\Projects-in-Progress\Trade Preparation Database Tool\JournalRequest.xslx", True

As you can see my Table Name is "JournalRequest" and I have hard-coded the path to the Output File I want to create.

I CAN achieve outputting my data to other Text Files (CSV, TXT) formats using Export Specifications I create. BUT I *think* that there HAS to be a way to do what I'm attemption.  Help!
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

so, what is the problem?
do you mean, using a variable as the name of the .xlsx file?

dim strTable
strTable="JournalRequest"

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, strTable, "H:\WBC\Projects-in-Progress\Trade Preparation Database Tool\" & strTable & ".xslx", True
You spelled the extension wrong

.xlsx
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tom_wbi
Tom_wbi

ASKER

Hi All - No I mean it does not work.

For example, using:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "JournalRequest", "H:\WBC\Projects-in-Progress\Trade Preparation Database Tool\JournalRequest.xslx", True

Generates Run-time Error 3027. 'Cannot Update. Database or object is read-only'

When I modify the command as such:

DoCmd.TransferText acExport, acSpreadsheetTypeExcel12Xml, "JournalRequest", "H:\WBC\Projects-in-Progress\Trade Preparation Database Tool\JournalRequest.xslx", True

The error becomes: 'You cannot import this file' even though I'm trying to do an EXPORT.

So, I must have some syntax wrong with my command - perhaps a bad constant??

Sorry I wasn't more clear, initially.


the .xslx is wrong (.xlsx) as pointed out by jeff, unless it is just a typo error
Avatar of Tom_wbi

ASKER

OMG!!!

I am partially dyslexic and could NOT see that I was transposing the 'l' and 's'.  Thank you so much for taking the time to notice this!!!!!!
1. First you are never stating what actually happens when it "Does not work"
Nothing happens?
Wrong output format?
Access Crashes?
Error message?

You will get some type of read only error, and the Export will "Not Work" when you spell the extension incorrectly as you have done in the code you posted.

Please correct this misspelling and tell us if that fixes this issue.

JeffCoachman
Thanks...

It is a common mistake.

;-)

Jeff