Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Selecting File and FilePath

Hope somebody can help, can not find the answer in my books...

I am used to coding for XL95 but now have to use XL2000 (I prefer it but I'm
not used to it, the boss wants everything done yesterday)

I want to be able to select a file and file path using a built-in dialog box
and the file,filepath variables to be used in the procedure.

To be more specific, I want to import data from a text file, but rather than
forcing the user to have the text file in a specific place I want to allow
the user to select the file and where it is on their computer, the import
procedure will then use the supplied filepath/filename for importing the
data.

In XL95 I could use the open file dialog, select the file then when the
dialog was dismissed the file was not opened but the information gathered
could be used in the procedure. Can something like this be done in XL2000?
any help would be appreciated.
--
TIA

Pete


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Selecting File and FilePath

Peter,

You can use the GetOpenFilename procedure to do this. E.g.,

Dim FName As Variant
FName = Application.GetOpenFilename("Text Files (*.txt),*.txt", , , , False)
If FName = False Then
MsgBox "No File Selected"
Else
MsgBox "You chose: " & FName
End If

Note that GetOpenFilename does not actually open the file. It simply
returns the full file name selected by the user, or False if the user hits
cancel.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Peter Harrison" wrote in message
...
Hope somebody can help, can not find the answer in my books...

I am used to coding for XL95 but now have to use XL2000 (I prefer it but

I'm
not used to it, the boss wants everything done yesterday)

I want to be able to select a file and file path using a built-in dialog

box
and the file,filepath variables to be used in the procedure.

To be more specific, I want to import data from a text file, but rather

than
forcing the user to have the text file in a specific place I want to allow
the user to select the file and where it is on their computer, the import
procedure will then use the supplied filepath/filename for importing the
data.

In XL95 I could use the open file dialog, select the file then when the
dialog was dismissed the file was not opened but the information gathered
could be used in the procedure. Can something like this be done in XL2000?
any help would be appreciated.
--
TIA

Pete




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Selecting File and FilePath

Thanks very much. Exactly what I wanted, just couldn't find it using help or
the books.

Cheers,
Pete
"Chip Pearson" wrote in message
...
Peter,

You can use the GetOpenFilename procedure to do this. E.g.,

Dim FName As Variant
FName = Application.GetOpenFilename("Text Files (*.txt),*.txt", , , ,

False)
If FName = False Then
MsgBox "No File Selected"
Else
MsgBox "You chose: " & FName
End If

Note that GetOpenFilename does not actually open the file. It simply
returns the full file name selected by the user, or False if the user hits
cancel.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Peter Harrison" wrote in message
...
Hope somebody can help, can not find the answer in my books...

I am used to coding for XL95 but now have to use XL2000 (I prefer it but

I'm
not used to it, the boss wants everything done yesterday)

I want to be able to select a file and file path using a built-in dialog

box
and the file,filepath variables to be used in the procedure.

To be more specific, I want to import data from a text file, but rather

than
forcing the user to have the text file in a specific place I want to

allow
the user to select the file and where it is on their computer, the

import
procedure will then use the supplied filepath/filename for importing the
data.

In XL95 I could use the open file dialog, select the file then when the
dialog was dismissed the file was not opened but the information

gathered
could be used in the procedure. Can something like this be done in

XL2000?
any help would be appreciated.
--
TIA

Pete






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
Cell value becomes filepath to insert picture,jpg or object Rookie_User Excel Worksheet Functions 0 February 6th 07 04:32 PM
Can I set a default to add a filepath footer when printing? bearcat1 Excel Discussion (Misc queries) 0 August 3rd 06 09:21 PM
Filepath Marie-Jo Excel Discussion (Misc queries) 3 July 5th 05 07:56 PM
Filepath Marie-Jo Excel Discussion (Misc queries) 2 June 30th 05 11:06 PM
Selecting a filepath based on cell contents ceemo Excel Discussion (Misc queries) 1 June 25th 05 01:40 PM


All times are GMT +1. The time now is 03:44 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"