Results 1 to 2 of 2

Setting up a Query without refreshing

Threaded View

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Setting up a Query without refreshing

    I want to set up a query to download data from a Text file before I want to run the query.
    I have tried the following code
    Sub QuerySetUp(FileNameFrom, SheetNameTo )
    
    
    FilePath = Sheets("Employees").Range("P23").Value
    With Sheets(SheetNameTo)
       
        With .QueryTables.Add(Connection:= _
            "TEXT;" & FilePath & FileNameFrom & ".Txt", Destination:=.Range("$A$8"))
          
            .Name = SheetName
            .FieldNames = True
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .RefreshStyle = xlOverwriteCells
            .SavePassword = False
            .SaveData = True
            .AdjustColumnWidth = True
            .RefreshPeriod = 0
            .TextFilePromptOnRefresh = False
            .TextFilePlatform = 850
            .TextFileStartRow = 1
            .TextFileParseType = xlDelimited
            .TextFileTextQualifier = xlTextQualifierDoubleQuote
            .TextFileConsecutiveDelimiter = False
            .TextFileTabDelimiter = True
            .TextFileSemicolonDelimiter = False
            .TextFileCommaDelimiter = False
            .TextFileSpaceDelimiter = False
            .TextFileColumnDataTypes = Array(1)
            .TextFileTrailingMinusNumbers = True
           ' .Refresh BackgroundQuery:=False
        End With 
      End With   
    End Sub
    hoping that commenting out the penultimate Refresh line would set up the connection for future refreshes without actually refreshing, but this does not seem to happen. How do I add a connection?
    John
    Last edited by j_Southern; 11-12-2014 at 10:50 AM. Reason: code wrong

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Help! Query Refreshing
    By Emma Hope in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-16-2020, 11:37 PM
  2. Refreshing Web Query
    By Reznorz in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 03-22-2012, 05:34 AM
  3. Microsoft query and refreshing help
    By skywalkman-GB in forum Excel General
    Replies: 0
    Last Post: 06-24-2011, 05:54 AM
  4. MS Query Not Auto Refreshing
    By JuSlaughter in forum Excel General
    Replies: 2
    Last Post: 03-21-2007, 01:59 PM
  5. [SOLVED] Refreshing a database query
    By SeeKY in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-08-2005, 08:45 PM

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