Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default .GetOpenFilename assitance

Hi, using XL 2000
A simple task but struggling over a solution:
The following reports the file path AND name..

FileToOpen = Application.GetOpenFilename _
("All Files (*.*), *.*")

If FileToOpen < False then
MsgBox "Open " * FileToOpen
End if

I just need the filename.

Any ideas?

Thanks, Paul

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default .GetOpenFilename assitance

Hi Paul,

Try this
Dim FSO As Object
Dim FileToOpen

FileToOpen = Application.GetOpenFilename _
("All Files (*.*), *.*")

If FileToOpen < False Then
Set FSO = CreateObject("Scripting.FileSystemObject")
MsgBox "Open " & FSO.getfile(FileToOpen).Name
Set FSO = Nothing
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Paul" wrote in message
...
Hi, using XL 2000
A simple task but struggling over a solution:
The following reports the file path AND name..

FileToOpen = Application.GetOpenFilename _
("All Files (*.*), *.*")

If FileToOpen < False then
MsgBox "Open " * FileToOpen
End if

I just need the filename.

Any ideas?

Thanks, Paul



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default .GetOpenFilename assitance

Thanks bob. Its pulled the fulename.
How would I use this variable to display a workbook?
(make active)

Paul


Dim FileToOpen

FileToOpen = Application.GetOpenFilename _
("All Files (*.*), *.*")

If FileToOpen < False Then
Set FSO = CreateObject
("Scripting.FileSystemObject")
MsgBox "Open " & FSO.getfile(FileToOpen).Name
Set FSO = Nothing
End If


-----Original Message-----
Hi Paul,

Try this
Dim FSO As Object
Dim FileToOpen

FileToOpen = Application.GetOpenFilename _
("All Files (*.*), *.*")

If FileToOpen < False Then
Set FSO = CreateObject

("Scripting.FileSystemObject")
MsgBox "Open " & FSO.getfile(FileToOpen).Name
Set FSO = Nothing
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Paul" wrote in

message
...
Hi, using XL 2000
A simple task but struggling over a solution:
The following reports the file path AND name..

FileToOpen = Application.GetOpenFilename _
("All Files (*.*), *.*")

If FileToOpen < False then
MsgBox "Open " * FileToOpen
End if

I just need the filename.

Any ideas?

Thanks, Paul



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default .GetOpenFilename assitance

Dim sStr as String, wkbk as Workbook
sStr = FSO.getfile(FileToOpen).Name
on error resume next
set wkbk = Workbooks(sStr)
On error goto 0
if not wkbk is nothing then
wkbk.activate
else
msgbox sStr & " is not currently open"
End if

--
Regards,
Tom Ogilvy


"Paul" wrote in message
...
Thanks bob. Its pulled the fulename.
How would I use this variable to display a workbook?
(make active)

Paul


Dim FileToOpen

FileToOpen = Application.GetOpenFilename _
("All Files (*.*), *.*")

If FileToOpen < False Then
Set FSO = CreateObject
("Scripting.FileSystemObject")
MsgBox "Open " & FSO.getfile(FileToOpen).Name
Set FSO = Nothing
End If


-----Original Message-----
Hi Paul,

Try this
Dim FSO As Object
Dim FileToOpen

FileToOpen = Application.GetOpenFilename _
("All Files (*.*), *.*")

If FileToOpen < False Then
Set FSO = CreateObject

("Scripting.FileSystemObject")
MsgBox "Open " & FSO.getfile(FileToOpen).Name
Set FSO = Nothing
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Paul" wrote in

message
...
Hi, using XL 2000
A simple task but struggling over a solution:
The following reports the file path AND name..

FileToOpen = Application.GetOpenFilename _
("All Files (*.*), *.*")

If FileToOpen < False then
MsgBox "Open " * FileToOpen
End if

I just need the filename.

Any ideas?

Thanks, Paul



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 340
Default .GetOpenFilename assitance

Paul, the follwoing should do it (untested)

for I = len(FileToOpen) to 1 step -1
if mid(FileToOpen,I,1)="\" Then
JustFileName = mid(FileToOpen, I+1)
exit For
end if
Next

Robert Flanagan
Macro Systems
Delaware, U.S. 302-234-9857
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"Paul" wrote in message
...
Hi, using XL 2000
A simple task but struggling over a solution:
The following reports the file path AND name..

FileToOpen = Application.GetOpenFilename _
("All Files (*.*), *.*")

If FileToOpen < False then
MsgBox "Open " * FileToOpen
End if

I just need the filename.

Any ideas?

Thanks, Paul





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default .GetOpenFilename assitance

Hi,
another way using InStrRev function

JustFileName= Mid(FileToOpen, InStrRev(FileToOpen, "\") + 1)

Jare

--
Message posted from http://www.ExcelForum.com

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default .GetOpenFilename assitance

But that is not available in XL97, so Bob 's solution is more robust.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Jarek " wrote in message
...
Hi,
another way using InStrRev function

JustFileName= Mid(FileToOpen, InStrRev(FileToOpen, "\") + 1)

Jarek


---
Message posted from http://www.ExcelForum.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
Formula assitance needed Codeman Excel Worksheet Functions 3 March 5th 09 02:39 PM
Assitance W/ An If/Then formula japc90 Excel Discussion (Misc queries) 2 April 26th 08 03:33 PM
GetOpenFileName Greg Bloom Excel Programming 2 February 9th 04 04:09 PM
getopenfilename inquirer Excel Programming 1 December 3rd 03 11:37 AM
GetOpenFilename Hasan Cansü Excel Programming 0 September 24th 03 01:32 PM


All times are GMT +1. The time now is 08:13 PM.

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

About Us

"It's about Microsoft Excel"