Results 1 to 2 of 2
  1. #1
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150

    Exporting Table To Excel

    Hi Guys

    I used below code to export my Employee table to excel. but below code just shows the result in excel.



    Code:
        Dim curPath As String              Dim xlApp As Object
    
    
            curPath = CurrentProject.Path & "\Lec_Details - " & Format(Date, "mm-dd-yyyy")
            DoCmd.TransferSpreadsheet acExport, 10, "Employee", curPath, -1
    
    
            Set xlApp = CreateObject("Excel.Application")
            xlApp.Workbooks.Open (curPath)
            xlApp.Visible = True
    i have two problems.

    1.How can i set a default location/path to save the excel? (D:\Backup\
    2.How to export the table with formatting and layout?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    curPath = "D:\Backup\Lec_Details - " & Format(Date, "mm-dd-yyyy") & ".xlsx"
    vTbl = "Employee"
    docmd.TransferSpreadsheet acExport ,acSpreadsheetTypeExcel12,vTbl, curPath , true,"sheetName"

    you cannot export format, youd have to open excel, and format everything...
    xlApp.rows("1:1").Selection.Interior.ColorIndex = vbBlue

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

Similar Threads

  1. Problem exporting table to excel
    By JackieEVSC in forum Programming
    Replies: 9
    Last Post: 09-21-2016, 10:48 AM
  2. Exporting a Table to MS Excel problem
    By nosec in forum Import/Export Data
    Replies: 9
    Last Post: 11-05-2013, 11:28 AM
  3. Replies: 1
    Last Post: 09-06-2012, 12:33 PM
  4. Replies: 1
    Last Post: 04-05-2012, 01:08 PM
  5. Exporting from a Access Table to Excel PivotTable
    By runthis457 in forum Import/Export Data
    Replies: 2
    Last Post: 02-12-2011, 09:06 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