+ Reply to Thread
Results 1 to 5 of 5

Thread: Retrieve the filename of the workbook connection

  1. #1
    Registered User
    Join Date
    09-18-2011
    Location
    Southampton
    MS-Off Ver
    Excel 2007
    Posts
    7

    Retrieve the filename of the workbook connection

    Hello everyone
    I was wondering if anyone could point me in the right direction with workbook connections.

    So...I have a connection which is from a text file. Using a button the user of my workbook will refresh this data by selecting the most recent text file from a list in a windows directory. The problem I am having is I would like to know what file the data is being drawn from.

    To refresh the data I just use ActiveWorkbook.RefreshAll

    I am able to extract the workbook connection name with the use of this:
    Sub one()
    Dim conn As WorkbookConnection
    
    For Each conn In ActiveWorkbook.Connections
    MsgBox conn.name
    Next conn
    End Sub
    The issue is that its not the connection name I want, its the data file name I want instead.

    If anyone can help then that would be brilliant. Thanks alot in advance

  2. #2
    Registered User
    Join Date
    09-18-2011
    Location
    Southampton
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Retrieve the filename of the workbook connection

    Hi

    Does anyone have any ideas please?
    Thanks

  3. #3
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    02-15-2008
    Location
    Grappenhall, UK
    MS-Off Ver
    Excel for Windows & Mac - all versions.
    Posts
    6,566

    Re: Retrieve the filename of the workbook connection

    Can you clarify.
    Your thread title explicitly says you want the connection name. Your penultimate sentence says otherwise

    You mention a 'data file'. What's this?
    Richard Buttrey

    If this was useful then please rate it appropriately.

    Click the small star icon at the bottom left of my post.

  4. #4
    Registered User
    Join Date
    09-18-2011
    Location
    Southampton
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Retrieve the filename of the workbook connection

    Hi, sorry to confuse, thought the title was clear.
    I have imported data from a text file (csv) thats organised on a worksheet. This text file is named as a date, for example 01-01-2012.txt. When I initially set up the connection, I gave the connection a name of something like 'Route & call info'.
    My workbook requires the user to refresh the connection every time they use it but the text file they refresh their data from could change. i.e. the text file may be replaced by 02-01-2012.txt. The connection name (Route & call info) always stays the same but the filename where the data is coming from changes.

    Its the filename of the text file that is supplying the data that I want to capture.

    Hope thats a little clearer?

    Thanks

  5. #5
    Registered User
    Join Date
    09-18-2011
    Location
    Southampton
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Retrieve the filename of the workbook connection

    Last attempt at trying to resource the answer!...
    Apologies if this is frowned upon here!...|

    Kris

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0