Results 1 to 5 of 5
  1. #1
    joanas is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    9

    Export data to excel

    hi,



    how can i export data from a table (access) to the excel?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    A number of ways. Manually with the External Data tab, in macro or VBA code using TransferSpreadsheet or in VBA using automation.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    joanas is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    9
    i'm usingvba code. and i tried this code:



    Sub importtoexcel()


    Dim XL As Excel.Application
    Dim wbtarget As Workbook
    Dim qdfFlintstones As QueryDef
    Dim rsFlintstones As Recordset


    Set qdfFlintstones = CurrentDb.QueryDefs("t_mes_fec_data")


    Set rsFlintstones = qdfFlintstones.OpenRecordset()


    Set XL = CreateObject("Excel.Application")


    Set wbtarget = XL.Workbooks.Open("G:\OrcControlo\SCC\Joana\Prepar ar_F01Incos02.xlsm")


    wbtarget.Worksheets("DCRH_centro_6971").Cells.Clea rContents


    wbtarget.Worksheets("DCRH_centro_6971").Cells(1, 1).CopyFromRecordset rsFlintstones




    wbtarget.Save
    wbtarget.Close


    Set wbtarget = Nothing
    Set XL = Nothing


    Set qdfflintsones = Nothing


    End Sub



    but the code stops here: Set rsFlintstones = qdfFlintstones.OpenRecordset()

    can you explain me why?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    What's the error?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    You don't need the querydef.

    It should work fine by just using:

    Set rsFlintstones = currentdb.OpenRecordset("t_mes_fec_data")


    But instead of doing all that, look into using the TransferSpreadsheet method:

    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "t_mes_fec_data", "G:\OrcControlo\SCC\Joana\Prepar ar_F01Incos02.xlsm"

    would be a good starting point.

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

Similar Threads

  1. Export to excel form data
    By Moopsz in forum Macros
    Replies: 4
    Last Post: 12-18-2014, 02:03 PM
  2. export data from subform to excel
    By raffi in forum Import/Export Data
    Replies: 2
    Last Post: 11-02-2014, 03:40 PM
  3. How to export all data to excel?
    By s128 in forum Import/Export Data
    Replies: 5
    Last Post: 06-17-2013, 01:22 PM
  4. export data on excel file
    By Mina Garas in forum Queries
    Replies: 1
    Last Post: 12-01-2012, 02:43 PM
  5. trying to export table data tpo Excel
    By itm in forum Access
    Replies: 2
    Last Post: 01-30-2012, 10: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