Results 1 to 3 of 3
  1. #1
    Fostertrident is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    32

    VBA query - Excel export

    Hi



    I'm using the following code to export an access query to excel:

    Code:
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Ready for letter", "C:\Users\XXXXX\Readyforlettersend.xlsx"
    , True

    Is there any way of adding some code to ensure that when the query is exported to excel it's exported as a table.

    I tried recording a macro to see how excel makes a Table but i can't seem to integrate it into my VBA code in access.

    Code:
    ListObjects.Add(xlSrcRange, Range("$A$1:$Q$3"), , xlYes).Name = _            "Table1"
            Range("Table1[#All]").Select
    Many thanks in advance.

    Kind regards

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    your export is correct, but you'd need to use vba to open the file after export, then build your table.

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,000
    Why not send the letter data straight from Access?
    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

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

Similar Threads

  1. Replies: 2
    Last Post: 05-19-2021, 02:38 AM
  2. Replies: 1
    Last Post: 10-18-2019, 06:09 AM
  3. Replies: 7
    Last Post: 04-25-2013, 03:47 PM
  4. Export Query into Excel
    By system243trd in forum Programming
    Replies: 1
    Last Post: 11-24-2012, 08:51 AM
  5. Replies: 3
    Last Post: 10-07-2011, 07:49 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