Results 1 to 8 of 8
  1. #1
    ashu.doc is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    124

    Report to save as Excel file

    Hi Everyone


    I want to save my report as excel file on the user computer with
    a click of a button. I have tried this code:

    Private Sub
    Cmd_ReporttoExcel_Click()
    DoCmd.OutputTo acOutputReport, "Gastrolog Report",
    acFormatXLS, "C:\Users\XX\Documents" & Format(Date, "yyyymmdd") &
    ".xls"
    End Sub

    But it is giving error 2282 - The format in which you
    are attempting to output the current object is not available.

    The other
    part of this question is :
    This
    is something similar when I didn't have "PDF add in " in access 2007, when I
    added PDF add in then option to save file in PDF was available in "output to"
    action of macro. There is nothing like \excel add in. However when I can export
    the data in excel sheet by Export function in access why don't I have option to
    save file as excel in "output to " action in macro? I want to have this option
    so that user can click a button in the form rather than in the top ribbon try to
    find out how to transfer and save the excel sheet.

    many thanks
    Ash

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,951
    Is Documents a folder? Need "\" between it and the file name.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ashu.doc is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    124
    Do you mean this?

    Private Sub
    Cmd_ReporttoExcel_Click()
    DoCmd.OutputTo acOutputReport, "Gastrolog Report", acFormatXLS, "C:\Users\XX\Documents\GastroLog" & Format(Date, "yyyymmdd") & ".xls"
    End Sub

    I have tried this but same error. Is it because the "save as Excel" add in is not available is access 2007?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,951
    I have never had issue with OutputTo for Excel in 2007 or 2010. I have never installed any 'save as Excel add-in'. Do you have Excel application installed?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    ashu.doc is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    124
    Yes I have it installed, you are right, that it should not have an issue because both the access and excel are from Microsoft and if you see the data can be exported from access to excel by export option but the macros isn't having an option to export it as excel?
    I have tried to change the code a little bit and instead of acFormatXLS I have used acFormatExcelWorkbook, which on click event opens a little window to choose several file format to save like html, rtf, pdf, xml etc. and when I click html as option it is saving the report in excel format with an error message saying the file you are saving is corrupt although it is saving ok in the end.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I did not have any trouble with either of the following using Office 2013. Make sure you do not have an existing Excel file in the directory and you are using the .xls extension, not the xlsx.

    Code:
    DoCmd.OutputTo acOutputReport, "ReportName", acFormatXLS, "C:\Test\ExcelFiles\Test.xls"
    
    DoCmd.OutputTo acOutputReport, "ReportName", "Microsoft Excel (*.xls)", "C:\Test\ExcelFiles\Test2.xls"

  7. #7
    ashu.doc is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    124
    Hi Everyone
    I have sorted this out in a different way, as we know access 2007 SP1 does not support saving report as excel, but it does support saving table data as excel!! So I just had to change that in Macro and works perfect.
    Thanks all

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,951
    Apparently I never tried to export report with Access 2007, just table/query, and never became aware of that issue. Thanks for the followup.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. excel compatibility checker, file save issue
    By trevor40 in forum Programming
    Replies: 2
    Last Post: 12-04-2014, 07:59 PM
  2. Save As dialog box exporting Excel file
    By accessnewbie in forum Access
    Replies: 1
    Last Post: 03-09-2013, 03:15 PM
  3. Open,new and save as an excel target file
    By dacodac in forum Programming
    Replies: 7
    Last Post: 01-31-2013, 05:25 AM
  4. Close and Save Excel file already opened in Access
    By DB2010MN26 in forum Programming
    Replies: 7
    Last Post: 01-19-2012, 06:50 PM
  5. Open / Save as Excel File and specifiy format
    By jaykappy in forum Access
    Replies: 8
    Last Post: 03-24-2009, 03:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums