Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Sort by file/directory like explorer | Excel Discussion (Misc queries) | |||
Excel should let me sort the file directory when saving a file | Excel Discussion (Misc queries) | |||
auto file path update when excel sheet moved to another directory. | Excel Discussion (Misc queries) | |||
How do I insert the directory path in my Excel file? | Excel Worksheet Functions | |||
How set file open path to filepath of file opened with Explorer ? | Excel Programming |