Results 1 to 4 of 4
  1. #1
    uoghk is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jan 2022
    Posts
    149

    Report exports to Excel but cannot open

    I use below code to generate a Excel file for client A123 statement.
    The Excel file is exported.


    But cannot open with message "File format or file extension is not valid"
    Code:
    DoCmd.OpenReport "rptStatement", acViewPreview, , "CustNo='A123'", acHidden
    DoCmd.OutputTo acOutputReport, "rptStatement", acFormatXLS, "C:\Temp\A123Statement.xlsx"
    Do I need to remove the statement's header and just leave the detail section ?
    Thanks

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Well I would start by changing the extension to .xls?
    What version of Office are you using?

    Then again I have Google on this laptop.

    https://www.devhut.net/docmd-outputt...l-2007-format/

    https://www.devhut.net/access-bug-do...x-doesnt-work/
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    use: docmd.Transferspreadsheet,acSpreadsheetTypeExcel12 Xml

    it opens w/o complaint.

  4. #4
    uoghk is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jan 2022
    Posts
    149
    thank ranman256.
    it works.

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

Similar Threads

  1. Replies: 19
    Last Post: 10-31-2017, 09:01 AM
  2. Replies: 9
    Last Post: 08-26-2016, 12:52 PM
  3. Replies: 1
    Last Post: 03-11-2014, 09:29 AM
  4. Replies: 1
    Last Post: 01-22-2013, 09:51 AM
  5. Problem with Query exports to Excel
    By nokeefe in forum Access
    Replies: 9
    Last Post: 12-07-2011, 12:50 AM

Tags for this Thread

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