+ Reply to Thread
Results 1 to 3 of 3

Refresh query from text source without manually selecting text file each time

  1. #1
    Registered User
    Join Date
    06-27-2013
    Location
    New Hampshire, USA
    MS-Off Ver
    Excel 2010
    Posts
    25

    Refresh query from text source without manually selecting text file each time

    There is a text file set up to automatically pull and compile data from multiple sources, and it refreshes once every day. I use that text source to populate some tables in my own spreadsheet, and have set up a query. I have a macro which I can currently run manually in order to refresh all the data, but it prompts me to select the text file containing the data I am importing each time. The file name or location is never going to change, so ideally I would like that refresh macro to run with a set frequency (I think I can figure that out with a bit of googling around), and also choose the text file automatically- I don't want there to be any manual selection of the data source.

    Any help would be hugely appreciated.

  2. #2
    Registered User
    Join Date
    06-21-2013
    Location
    Wiltshire, UK
    MS-Off Ver
    365 Version 2210 Build 16.0.15726.20070
    Posts
    72

    Re: Refresh query from text source without manually selecting text file each time

    How is the data in the text file separated? Assuming it to be comma delimited (CSV) you can open it as a workbook - Application.Workbooks.Open (FULLPATH & FILENAME). So to open ThisData.csv in folder DownLoadData on drive K it would be Application.Workbooks.Open("K:\DownLoadData\ThisData.csv"). This will open your text file and make it accessible to you. I would suggest you create a variable to hold your textfile as your code will refer to it a lot (you may already do this any way). EG

    Please Login or Register  to view this content.
    Isskint, i get satisfaction out of helping others

  3. #3
    Registered User
    Join Date
    06-27-2013
    Location
    New Hampshire, USA
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Refresh query from text source without manually selecting text file each time

    I have a workbook consisting of 3 sheets. Using the workbook command opens the CSV file as a workbook in place of my current workbook rather than opening it in place of the current sheet I'm on. The other problem is that this just opens the data exactly as is, and doesn't preseve any of the import preferences/settings I established when manually doing it through a query. At worst I need to be able to open it in a sheet within the current workbook, but at best I just need a way to do the refresh automatically without having to manually specify the file each time.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1