Results 1 to 3 of 3
  1. #1
    Eddy Sincere is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Location
    Carson City, NV
    Posts
    114

    Export query to a specific sheet/tab in an Excel spreadsheet

    I may have already posted this question, but when I go to my profile it's not showing up. If I already have please disregard this one. Anyway, I need to export a query to excel (which is working alright). However, what I really need is to export to a specific sheet/tab within the spreadsheet. UNfortunately, I don't know the specific syntax to use and I'm having trouble finding it. Here's the VBA I'm using for the export (Yes, I converted it from a macro. I'm still new at this whole VBA thing):

    Private Sub Command0_Click()
    On Error GoTo Command0_Click_Err

    DoCmd.OutputTo acOutputQuery, "qryExprd", "ExcelWorkbook(*.xlsx)", "C:\Users\XXX\XXX\Database\ControlledDocs\Test.xls x", False, "", , acExportQualityPrint



    Command0_Click_Exit:
    Exit Sub

    Command0_Click_Err:
    MsgBox Error$
    Resume Command0_Click_Exit

    End Sub


    Can I just add the sheet/tab name at the end of the file path? Something like: Test.xlsx.Sheet 1

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,943
    AFAIK, that won't work. Can't use OutputTo nor TransferSpreadsheet for that. Open Excel objects in VBA and manipulate the objects. Review http://www.accessmvp.com/KDSnell/EXC...m#WriteRstFile
    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
    Eddy Sincere is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Location
    Carson City, NV
    Posts
    114
    As usual, this is the perfect solution. Thanks for the reference. I plugged in the code, made a few changes and it's working perfectly. Problem solved.

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

Similar Threads

  1. Export query or report to preformatted excel sheet
    By andrewmo in forum Import/Export Data
    Replies: 3
    Last Post: 08-13-2013, 10:11 AM
  2. Replies: 1
    Last Post: 05-23-2013, 10:00 AM
  3. Cant Export data to specific excel sheet by ADODB
    By rangga_osh in forum Import/Export Data
    Replies: 4
    Last Post: 03-14-2013, 04:20 AM
  4. Export Query to specific excel sheet
    By Perceptus in forum Queries
    Replies: 2
    Last Post: 12-20-2012, 11:50 AM
  5. Export Query to Specific Sheet and Rows/Columns
    By chewbears in forum Queries
    Replies: 7
    Last Post: 11-30-2011, 09:44 AM

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