Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Extract full path given filename

Is there a way to extract the full file path into a
message box given just the file name? For example, if I
entered "Testfile.xls" into an input box, I would like
Excel to go out and find the path. It would then return a
message box that says something like:

"c:\programs\excel\myfiles\friday\Testfile.xls "

I've tried . . .

Sub FindPath()
Dim MyFile As String
MyFile = ActiveWorkbook.FullName
MsgBox MyFile
End Sub

but it only works for the active workbook. I would like
to enter any file name and have it return the correct path.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Extract full path given filename

Hi
do you mean you want your code to search the entire harddisc for this
file?

--
Regards
Frank Kabel
Frankfurt, Germany


Kim J. wrote:
Is there a way to extract the full file path into a
message box given just the file name? For example, if I
entered "Testfile.xls" into an input box, I would like
Excel to go out and find the path. It would then return a
message box that says something like:

"c:\programs\excel\myfiles\friday\Testfile.xls "

I've tried . . .

Sub FindPath()
Dim MyFile As String
MyFile = ActiveWorkbook.FullName
MsgBox MyFile
End Sub

but it only works for the active workbook. I would like
to enter any file name and have it return the correct path.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Extract full path given filename

Kim

I guess one way would be:

Windows("Testfile.xls").Activate
Debug.Print ActiveWorkbook.Path
Debug.Print ActiveWorkbook.Name
Debug.Print ActiveWorkbook.FullName
ThisWorkbook.Activate

Regards

Trevor


"Kim J." wrote in message
...
Is there a way to extract the full file path into a
message box given just the file name? For example, if I
entered "Testfile.xls" into an input box, I would like
Excel to go out and find the path. It would then return a
message box that says something like:

"c:\programs\excel\myfiles\friday\Testfile.xls "

I've tried . . .

Sub FindPath()
Dim MyFile As String
MyFile = ActiveWorkbook.FullName
MsgBox MyFile
End Sub

but it only works for the active workbook. I would like
to enter any file name and have it return the correct path.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 691
Default Extract full path given filename

Hi Kim,
Excel can have only one workbook open with a given filename,
and you could efficiently provide the full pathname for that (I'm sure),
but you want Excel to search your entire hard drive, for filenames
holding up Excel for a search that could take a while and could
produce more than one file. So I think you need some rethinking.
On a network drive you'd kind of be hit and miss as you would only
have access to your files that you are allowed to see the filenames.
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Frank Kabel" wrote in message ...
Hi
do you mean you want your code to search the entire harddisc for this
file?

--
Regards
Frank Kabel
Frankfurt, Germany


Kim J. wrote:
Is there a way to extract the full file path into a
message box given just the file name? For example, if I
entered "Testfile.xls" into an input box, I would like
Excel to go out and find the path. It would then return a
message box that says something like:

"c:\programs\excel\myfiles\friday\Testfile.xls "

I've tried . . .

Sub FindPath()
Dim MyFile As String
MyFile = ActiveWorkbook.FullName
MsgBox MyFile
End Sub

but it only works for the active workbook. I would like
to enter any file name and have it return the correct path.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
http://CannotDeleteFile.net - Cannot Delete File? Try Long Path ToolFilename is too long? Computer Complaining Your Filename Is Too Long? TheLong Path Tool Can Help While most people can go about their businessblissfully unaware of the Windo Max Loger Excel Discussion (Misc queries) 0 June 14th 11 04:30 PM
Insert Full Path Roxy Excel Worksheet Functions 4 May 4th 07 09:31 PM
Full path possible to be seen? Octavio New Users to Excel 10 July 2nd 06 08:51 PM
Full path in title bar ntoze Excel Discussion (Misc queries) 0 February 21st 06 07:26 PM
Trim path from full filename Arawn Excel Programming 3 June 3rd 04 07:10 PM


All times are GMT +1. The time now is 05:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"