Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Is there an Excel GetOpenFilename Method which returns just the filename and not the file path ?

Posted on 2014-11-12
3
Medium Priority
?
113 Views
Last Modified: 2014-11-12
Hi All,

Is there a VBA method which will return me a string containing just the file name and not the full file path ?

Thanks
T
0
Comment
Question by:Tocogroup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 33

Accepted Solution

by:
Rob Henson earned 2000 total points
ID: 40437165
Include this line:

FileName = ActiveWorkbook.Name

Thanks
Rob H
0
 
LVL 26

Expert Comment

by:ProfessorJimJam
ID: 40437230
here it is

Sub test()
Dim f As String, OpenMsg As String, FileName As String

f = Application.GetOpenFilename(Title:="Select  File")


If f = "False" Then Exit Sub


FileName = Dir(f, vbDirectory)

MsgBox FileName

End Sub

Open in new window

0
 

Author Closing Comment

by:Tocogroup
ID: 40437232
Thanks Rob. That's great.
Toco
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

730 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