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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TransferSpreadsheet --acSpreadsheetType question

Status
Not open for further replies.

exRP12Nuke

Technical User
Oct 5, 2011
49
US
Good Afternoon,

I have a bit of code that exports a table in my database to an Excel Spreadsheet, but I cannot get it to save in .xlsx format, only in .xls format. What am I doing wrong? I assume that it is the Excel type that is the issue, but I cannot figure out which one I need to use.

Here is the bit of code.

Code:
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel5, "TblLastRI", _
        "G:\Data\EMS\Product Support\Contracts\Contract Reports\R&I Table Backup\ _
LastR&I Backup_" & Format(Date, "yyyymmdd") & ".xls", True

When I try to make the ".xls" part ".xlsx" the code does not run, I am at a loss.

Thanks!
 
dhookom,

acSpreadSheetTypeExcel12 does not work either, looking at the help file the highest that will go is acSpreadSheetTypeExcel9 (Excel 2000 format). Even with that I cannot get the .xlsx

Any other ideas?

Thanks!
 
What version of msaccess are you playing with ?
Should be at least 2007 for .xslx export ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
looking at the help file the highest that will go is acSpreadSheetTypeExcel9 (Excel 2000 format). Even with that I cannot get the .xlsx
THEREFORE, with your version of MS Access, you cannot use .xlsx as that is a 2007+ feature.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
MS ACCESS 2010 too ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yes, I have Microsoft Office Professional Plus which includes MS Access 2010.
 
and the version of Access that you have open is the 2010 version, as it is possible to have multiple versions of Access on your PC?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Nope, I only have one version of Access, I wish that I could put a screen print in here, but I have not figured out how to do that.

Is there another command besides TransferSpreadsheet that I would be able to use?

Thanks!
 
I rarely export to a spreadsheet, although I regularly query MS Access databases directly from a worksheet, in order to return data to my workbook.

Once a Query Table is added to a worksheet, it can be REFRESHED either automatically or on demand in Excel to get new data.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
I will try that approach, I have never queried out of Excel into Access before, but it never hurts to learn something new.

Overall, if it does not work, it is not that big of a deal, I just like to have everything as .xlsx, .docx, .pptx, etc...

Thanks again!
 
IMNSHO, a .doc* or .ppt* for extensive tabluar data is relatively useless, whereas an .xls* can be employed to slice 'n' dice the data to glean valuable views and summarizations where non-database types can manipulate the data in an extremely functional & popular tool.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Oh I agree, I was just trying to make the point that I like having the most recent versions of office documents. I rarely, if ever, put Access data into a .docx or .pptx unless I am giving a static presentation or generating instructions on how to utilze some of the databases that we manage.

Thanks!
 
exRP12Nuke - I don't know if this can be done, but if I had your problem, I'd try to find a way to code so that you the data in a *.zip file format, then within the same code to change the file name extension to *.xlsx. Since the xlsx file format is actually a zip file, I have found it useful in some cases to change an xlsx file extension to zip and then using WinZip to open and manipulate the components of the file independently of the rest of the components, then change it back to xlsx when I'm done. This suggestion would just be doing that in reverse, using the zip format as a stepping stone to the current excel format.

Another idea I'm not sure if possible but might work - Export to *.txt, then from within the access procedure, fire up excel, have excel run a procedure that opens and properly parses the txt file into columns and rows and do anything else you want to do with the data, saves as xlsx, then deletes the txt file.

Others - Can either of the above be done?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top