Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 300
Default Extract Workbook name from pathname ?

Using Application.GetOpenFilename I can find what file the user would like
to open. But before opening I want to be sure the file isn't already open.
Having the filename I can loop through the set of Application.Workbooks and
check. Problem is the GetOpenFilename returns the full pathname, and
Workbooks is a list of filenames only. So how do I easily extract the
filename from the pathname? I looked around and could not find a function.
If I have to I can loop through the name, find the slash (or colon), and do
a Right. But I would think that there is an easier way.

Thanks, Don <donwiss at panix.com.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Extract Workbook name from pathname ?

Don,

Try ActiveWorkbook.Path

Best Regards

Bill
-----Original Message-----
Using Application.GetOpenFilename I can find what file

the user would like
to open. But before opening I want to be sure the file

isn't already open.
Having the filename I can loop through the set of

Application.Workbooks and
check. Problem is the GetOpenFilename returns the full

pathname, and
Workbooks is a list of filenames only. So how do I easily

extract the
filename from the pathname? I looked around and could not

find a function.
If I have to I can loop through the name, find the slash

(or colon), and do
a Right. But I would think that there is an easier way.

Thanks, Don <donwiss at panix.com.
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 300
Default Extract Workbook name from pathname ?

On Mon, 29 Sep 2003 16:54:00 -0700, Bill Li wrote:

On Mon, 29 Sep 2003 19:25:58 -0400, Don Wiss wrote:

Using Application.GetOpenFilename I can find what file the user would like
to open. But before opening I want to be sure the file isn't already open.
Having the filename I can loop through the set of Application.Workbooks and
check. Problem is the GetOpenFilename returns the full pathname, and
Workbooks is a list of filenames only. So how do I easily extract the
filename from the pathname? I looked around and could not find a function.
If I have to I can loop through the name, find the slash (or colon), and do
a Right. But I would think that there is an easier way.


Try ActiveWorkbook.Path


Uh, how does that help me? I have a pathname in a string variable. (A
pathname in a string variable is the result of GetOpenFilename.) What
ActiveWorkbook I have open, and is running the macro, is irrelevant to the
problem.

Don <donwiss at panix.com.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Extract Workbook name from pathname ?

Try
s = Application.GetOpenFilename()

s1 = Dir(s)

s2 = Mid(s, 1, Len(s) - Len(s1))

s1 is the filename
s2 is the pathname

-----Original Message-----
On Mon, 29 Sep 2003 16:54:00 -0700, Bill Li

wrote:

On Mon, 29 Sep 2003 19:25:58 -0400, Don Wiss wrote:

Using Application.GetOpenFilename I can find what file

the user would like
to open. But before opening I want to be sure the file

isn't already open.
Having the filename I can loop through the set of

Application.Workbooks and
check. Problem is the GetOpenFilename returns the full

pathname, and
Workbooks is a list of filenames only. So how do I

easily extract the
filename from the pathname? I looked around and could

not find a function.
If I have to I can loop through the name, find the

slash (or colon), and do
a Right. But I would think that there is an easier way.


Try ActiveWorkbook.Path


Uh, how does that help me? I have a pathname in a string

variable. (A
pathname in a string variable is the result of

GetOpenFilename.) What
ActiveWorkbook I have open, and is running the macro, is

irrelevant to the
problem.

Don <donwiss at panix.com.
.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Extract Workbook name from pathname ?

fName = Application.GetOpenFileName()
for each bk in Workbooks
if ucase(bk.fullname) = ucase(fName) then
' workbook is open
end if
Next

--
Regards,
Tom Ogilvy

"Don Wiss" wrote in message
...
On Mon, 29 Sep 2003 16:54:00 -0700, Bill Li wrote:

On Mon, 29 Sep 2003 19:25:58 -0400, Don Wiss wrote:

Using Application.GetOpenFilename I can find what file the user would

like
to open. But before opening I want to be sure the file isn't already

open.
Having the filename I can loop through the set of Application.Workbooks

and
check. Problem is the GetOpenFilename returns the full pathname, and
Workbooks is a list of filenames only. So how do I easily extract the
filename from the pathname? I looked around and could not find a

function.
If I have to I can loop through the name, find the slash (or colon), and

do
a Right. But I would think that there is an easier way.


Try ActiveWorkbook.Path


Uh, how does that help me? I have a pathname in a string variable. (A
pathname in a string variable is the result of GetOpenFilename.) What
ActiveWorkbook I have open, and is running the macro, is irrelevant to the
problem.

Don <donwiss at panix.com.



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
vlookup dynamic pathname mdhodgson Excel Discussion (Misc queries) 3 September 5th 08 03:27 AM
How do use listed pathname to link values from another workbook? simplymidori[_2_] Excel Discussion (Misc queries) 1 July 19th 07 07:03 AM
Using a dynamic pathname in VLOOKUP Mike D[_2_] Excel Worksheet Functions 7 July 16th 07 09:35 PM
Full Pathname in Titlebar Greg Setting up and Configuration of Excel 3 March 25th 05 01:49 AM
LoadPicture Pathname or no Pathname Philipp Schramek Excel Programming 1 July 8th 03 03:30 PM


All times are GMT +1. The time now is 11:53 AM.

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"