Vb code for Exporting Access table to Excel

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sarah2855
    New Member
    • May 2010
    • 21

    #1

    Vb code for Exporting Access table to Excel

    Hello All,
    I'm looking for the vb code that export an access table to specific worksheet in Excel. I tried to search see if this question was answered before here, but didn't find anything that really relates to this question.

    I will appreciate your help,

    thanks in advance.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    Sarah,

    We don't generally work that way. We are happy to help you, and lead you to a certain extent, but we draw the line at simply providing boiler-plate code on request.

    If you would like to share what you've already tried and possibly ask a specific question related to where you're stuck then we can help further.

    I can tell you that using the following requires the table or QueryDef object being exported to have the same name as the worksheet you want to export it into :
    Code:
    DoCmd.TransferSpreadsheet()
    The TableName parameter would be the important one here.

    Comment

    • sarah2855
      New Member
      • May 2010
      • 21

      #3
      Thanks Neopa,

      Yes I'm using DoCmd.TransferS preadsheet() .Sorry I wasn't so clear in my question. My problem was when using TransferSpreads heet() after I open up the excel file I get error message because of the file type. The code I was using is:
      Code:
      DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "TABLE NAME", "FILE PATH", True, "WorkSheet Name"
      After I did a little bit of search , I figured I have to change acSpreadsheetTy peExcel12 to acSpreadsheetTy peExcel12Xml to create *.xlsx file type.

      Thanks for your reply,
      Sarah

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32669

        #4
        Good work Sarah :)

        I'm still using 2003 so know very little about 2007 specific facilities, as this would seem to be.

        Comment

        Working...