GetOpenFileName, then display that Filename in a box?
Results 1 to 5 of 5

Thread: GetOpenFileName, then display that Filename in a box?

  1. #1
    Board Regular
    Join Date
    Aug 2018
    Posts
    300
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default GetOpenFileName, then display that Filename in a box?

    Hi all, have a box with a button next to it, the idea is, user clicks the button which opens the directory where the Mailing Lists are stored, then the user selects the Mailing List and it stores the path + filename as "facml"

    I then want the box to fill in *just the file name*

    Here's my code below

    Code:
    ChDir "\\chw-dc03\company\Sales\Faculty Documents\2019 Mailing Lists"facml = Application.GetOpenFilename(Title:="Please choose a Faculty Mailing List")
    If facml = False Then
    Exit Sub
    End If
    Application.AskToUpdateLinks = True
    
    
    Range("D4").Value = facml
    What's happening right now is it's giving me the whole path + filename, I just need the filename to go in the box, thanks!

  2. #2
    Board Regular sykes's Avatar
    Join Date
    May 2002
    Location
    Cornwall,England
    Posts
    1,560
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default Re: GetOpenFileName, then display that Filename in a box?

    This should do the trick:
    Code:
    Dim str As String
    
    ChDir "\\chw-dc03\company\Sales\Faculty Documents\2019 Mailing Lists"
    facml = Application.GetOpenFilename(Title:="Please choose a Faculty Mailing List")
    If facml = False Then Exit Sub
    Application.AskToUpdateLinks = True
    
    str = Right(facml, Len(facml) - InStrRev(facml, "\", , 1))
    Range("D4").Value = str
    Sykes
    Windows 10 / XL 2016
    Members don't have crystal balls, so PLEASE describe your situation, code,
    and requirements ACCURATELY in your first post. It saves hair!
    Better still - upload your spreadsheet (and formulae!) with this great bit of kit.


    - forum use guidelines, forum rules and terms of use
    - Try searching for your answer first, see how
    - Read the FAQs
    - List of BB codes

  3. #3
    Board Regular
    Join Date
    Aug 2018
    Posts
    300
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: GetOpenFileName, then display that Filename in a box?

    Ah that's a great shout, well done and thanks.

  4. #4
    Board Regular sykes's Avatar
    Join Date
    May 2002
    Location
    Cornwall,England
    Posts
    1,560
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default Re: GetOpenFileName, then display that Filename in a box?

    Pleasure.
    Sykes
    Windows 10 / XL 2016
    Members don't have crystal balls, so PLEASE describe your situation, code,
    and requirements ACCURATELY in your first post. It saves hair!
    Better still - upload your spreadsheet (and formulae!) with this great bit of kit.


    - forum use guidelines, forum rules and terms of use
    - Try searching for your answer first, see how
    - Read the FAQs
    - List of BB codes

  5. #5
    Board Regular
    Join Date
    Aug 2018
    Posts
    300
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: GetOpenFileName, then display that Filename in a box?

    Quote Originally Posted by sykes View Post
    Pleasure.

    Got another one for you..

    The string I now need to extract is after the last "" and before the first instance of "Mailing_" but, the "Mailing_" needs to be wrapped in UCase as there are instances where it's either mailing or Mailing.

    I've been trying Mid with no results, but the syntax is lost on me

    Thanks


    Ah, kinda got there in a weird way with this:

    Code:
    spos = InStr(1, facml, "ists\") + 5epos = InStr(spos, facml, "ailing_") - 2
    camnam = Mid(facml, spos, epos - spos)
    Last edited by RockandGrohl; Jun 19th, 2019 at 12:31 PM.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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