Solved

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

Posted on 2014-11-12
3
100 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 500 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

623 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