Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Saving txt file from excel by specifying path - drop down directory explorer

Hi,
I am trying a save a txt file generated by excel to a folder in C
drive. I know how to save the file by writing the path. But, I was
wondering is it possible to see a drop down menu to select the
location(directory) and then giving the filename.

presently I am using this code to save a txt file....

Dim filename As Object
Set filename = Sheet1.Range("G79")

Open filename For Output As #1


I want to add a dropdown menu for the user to select the directory and
drive he wants to save his file in.

Please Help!!1

Thanks,

Rumeet

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Saving txt file from excel by specifying path - drop down director

Rummet,

If you want to open a dialog to save the file (ie get the save file name)
then try this:

Function GetSaveAsTxtFilename(Optional InitialFileName As Variant) As String
Dim vFilename As Variant
If IsMissing(InitialFileName) Then
InitialFileName = ""
End If
vFilename = _
Application.GetSaveAsFilename( _
InitialFileName:=InitialFileName, _
Title:="Please select a folder and name to save the file", _
filefilter:="Text files *.txt (*.txt),")
If vFilename = False Then
'cancel pressed
GetSaveAsTxtFilename = ""
Else
GetSaveAsTxtFilename = vFilename
End If
End Function

otherwise you will need to use a directory selection tool and take a look at
Jim Rech's code on Stephen Bullen's site
http://www.bmsltd.co.uk/MVP/Default.htm

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Riggi" wrote:

Hi,
I am trying a save a txt file generated by excel to a folder in C
drive. I know how to save the file by writing the path. But, I was
wondering is it possible to see a drop down menu to select the
location(directory) and then giving the filename.

presently I am using this code to save a txt file....

Dim filename As Object
Set filename = Sheet1.Range("G79")

Open filename For Output As #1


I want to add a dropdown menu for the user to select the directory and
drive he wants to save his file in.

Please Help!!1

Thanks,

Rumeet


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Saving txt file from excel by specifying path - drop down director

Thanks, it worked!!


Martin Fishlock wrote:
Rummet,

If you want to open a dialog to save the file (ie get the save file name)
then try this:

Function GetSaveAsTxtFilename(Optional InitialFileName As Variant) As String
Dim vFilename As Variant
If IsMissing(InitialFileName) Then
InitialFileName = ""
End If
vFilename = _
Application.GetSaveAsFilename( _
InitialFileName:=InitialFileName, _
Title:="Please select a folder and name to save the file", _
filefilter:="Text files *.txt (*.txt),")
If vFilename = False Then
'cancel pressed
GetSaveAsTxtFilename = ""
Else
GetSaveAsTxtFilename = vFilename
End If
End Function

otherwise you will need to use a directory selection tool and take a look at
Jim Rech's code on Stephen Bullen's site
http://www.bmsltd.co.uk/MVP/Default.htm

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Riggi" wrote:

Hi,
I am trying a save a txt file generated by excel to a folder in C
drive. I know how to save the file by writing the path. But, I was
wondering is it possible to see a drop down menu to select the
location(directory) and then giving the filename.

presently I am using this code to save a txt file....

Dim filename As Object
Set filename = Sheet1.Range("G79")

Open filename For Output As #1


I want to add a dropdown menu for the user to select the directory and
drive he wants to save his file in.

Please Help!!1

Thanks,

Rumeet



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Saving txt file from excel by specifying path - drop down director

How do I add another function to it which would ask the user to save it
in another name/replace the file if he is tryin to save a file which
already exists.

Please Help!!!!


Thanks,

Riggi


Riggi wrote:
Thanks, it worked!!


Martin Fishlock wrote:
Rummet,

If you want to open a dialog to save the file (ie get the save file name)
then try this:

Function GetSaveAsTxtFilename(Optional InitialFileName As Variant) As String
Dim vFilename As Variant
If IsMissing(InitialFileName) Then
InitialFileName = ""
End If
vFilename = _
Application.GetSaveAsFilename( _
InitialFileName:=InitialFileName, _
Title:="Please select a folder and name to save the file", _
filefilter:="Text files *.txt (*.txt),")
If vFilename = False Then
'cancel pressed
GetSaveAsTxtFilename = ""
Else
GetSaveAsTxtFilename = vFilename
End If
End Function

otherwise you will need to use a directory selection tool and take a look at
Jim Rech's code on Stephen Bullen's site
http://www.bmsltd.co.uk/MVP/Default.htm

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Riggi" wrote:

Hi,
I am trying a save a txt file generated by excel to a folder in C
drive. I know how to save the file by writing the path. But, I was
wondering is it possible to see a drop down menu to select the
location(directory) and then giving the filename.

presently I am using this code to save a txt file....

Dim filename As Object
Set filename = Sheet1.Range("G79")

Open filename For Output As #1


I want to add a dropdown menu for the user to select the directory and
drive he wants to save his file in.

Please Help!!1

Thanks,

Rumeet



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
Sort by file/directory like explorer NikiB Excel Discussion (Misc queries) 7 June 23rd 09 07:55 PM
Excel should let me sort the file directory when saving a file Beanee70 Excel Discussion (Misc queries) 0 March 14th 06 07:03 AM
auto file path update when excel sheet moved to another directory. GNSBoy Excel Discussion (Misc queries) 1 August 31st 05 07:46 PM
How do I insert the directory path in my Excel file? Insert a Directory Path in Header/Footer Excel Worksheet Functions 2 February 4th 05 09:23 PM
How set file open path to filepath of file opened with Explorer ? RandyDtg1 Excel Programming 0 May 14th 04 02:05 AM


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