Using a path and file name through varible in selection query table

Posted on 2009-04-17
Last Modified: 2013-12-25
With Selection.QueryTable
        .Connection = "TEXT;E:\Archive\Delivery\" & sfnametxt

now i want to use a variable that consists the entire file path and name instead of hardcoding it. What is the exact syntax
Question by:RamanaV
    LVL 39

    Accepted Solution

    You can do something like the following:

    Dim sPath As String = "E:\Archive\Delivery\"
    With Selection.QueryTable
            .Connection = "TEXT;" & sPath & sfnametxt

    Open in new window


    Author Closing Comment

    Thanks Abel for your quick response. it resolved my problem. Thanks once again and have a good weekend
    LVL 39

    Expert Comment

    glad it worked for you :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
    Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now