Access 2010 VBA Code to Export to Excel automatically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vbissues
    New Member
    • Feb 2014
    • 2

    Access 2010 VBA Code to Export to Excel automatically

    I am trying to understand how to write VB code in Access 2010 to automatically populate the data into multiple excel spreadsheets. The data in the query encompasses all the data (by manager), but I need to separate the files by manager. The files need to be automatically exported to excel with the name of each manager which should give me 32 exported files. I'm new to VBA and have read posts for the last 2 days and can't figure it out.
    Thanks in Advance
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    1. Post the SQL behind the Query.
    2. How is the Data to populate each individual Spreadsheet, by Year, Months, etc.?
    3. Do these Spreadsheets exist, or do they need to be dynamically created?
    4. These and other questions we will need to know the answers to in order to assist you.

    Comment

    • vbissues
      New Member
      • Feb 2014
      • 2

      #3
      I'm not sure what you mean post the SQL behind the query?
      The data is populate by manager, no time periods. Only one query exists and they need to dynamically created (split by manager).

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        vbissues
        Deep breath.
        Open the file
        Open the stored query in design view
        Right click on an empty area in the table display pane
        In the pop-up menu select SQL View
        You will now see the actual text behind the scenes
        Select all of this text
        Come back here
        Click on the [CODE/] button in the tool bar
        a pair of tags:
        [CODE] [/CODE]
        Will be inserted
        Paste your SQL text between these tags.


        -- You should also read thru:--

        Check your Bytes Inbox... I've PM'd you a list of helpfull sites.
        -z
        Last edited by zmbd; Feb 6 '14, 10:18 PM. Reason: [z{typo}]

        Comment

        • mcupito
          Contributor
          • Aug 2013
          • 294

          #5
          I think this is what you want?

          Code:
           outputFileName = CurrentProject.Path & "\Reports\YourReportName.xlsx"
                      DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "YourName", outputFileName, True
          This should help get you started.

          Comment

          Working...