Results 1 to 5 of 5
  1. #1
    tomb is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Posts
    3

    Macro to import text then advanced specs into a table and export to excel

    I'm pretty new to access and have some experience in VBA. So I need to manually import a text file, link it by creating a linked table, using advanced specs to separate everything, and later exporting the table to excel to a specific area in the sheet. The goal is to be able to do that automatically, the only thing I've found so far is to use: DoCmd.TransferText but as I said I'm new and I'm not sure how to go through all of this. Using Access 2016 so I added a macro and entered the specification name, table name, and file name but nothing happens when I run. Any help or alternate way of doing this??? Thank you in advance!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    if you have the txt file linked as a table, then you would export it to excel as:
    docmd.Transferspreadsheet.....

  3. #3
    tomb is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Posts
    3
    So I got the importing, changing format, and creating table down for the macro using vba so now I just need to know how to make the access macro export it to a specific spot on a specific excel sheet. Does docmd.Transferspreadsheet..... let me specifically post somewhere?

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    As listed in the parameters :

    vFile = "c:\folder\myfile.xls"
    tabname = "myData"
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "qsData2Export", vFile, True,tabname

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Docmd.TransferSpreadsheet does not allow you to export
    to a specific spot on a specific excel sheet
    . To do that you need to use automation to create or open your Excel file, select your location and export the table there. Search for CopyFromRecordset and you should find many examples on the web-here is one:
    https://stackoverflow.com/questions/...yfromrecordset

    Cheers,
    Vlad

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

Similar Threads

  1. Import Specs and Text Files
    By Gloverb06 in forum Access
    Replies: 3
    Last Post: 03-15-2016, 01:43 PM
  2. Replies: 1
    Last Post: 10-24-2014, 05:55 AM
  3. Replies: 3
    Last Post: 10-08-2014, 11:05 AM
  4. Advanced Export To Excel
    By TH53 in forum Import/Export Data
    Replies: 2
    Last Post: 10-09-2013, 06:26 PM
  5. Text Import Specs
    By orcinus in forum Access
    Replies: 3
    Last Post: 06-23-2010, 11:50 AM

Tags for this Thread

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