Folder picker and save file

Muralikrishnan

New Member
Joined
Mar 15, 2009
Messages
20
Dear All,

I need VBA coding to coose a folder and same my file over there by using filderpicker.

Please help.

Thank you,
Murali.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Dear All,

I am able to use the below codes to save the file.
code/
Dim Myfolder As String
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Application.DefaultFilePath & "\"
.Title = "Select a folder..."
.Show
Myfolder = .SelectedItems(1) & "\"
End With

However, the file is saving one step up of the folder.
Please help.
Regards,
M
 
Upvote 0
The code you provides allows you to return the folder path in the varible "MyFolder", but it does not actually save a file.

You need to use the "SaveAs" function to save the file.

The following code uses your existing code and adds the saveas function.

Code:
Option Explicit
Sub Macro1()
    Dim FName As String
    Dim MyFolder As String
    With Application.FileDialog(msoFileDialogFolderPicker)
        .InitialFileName = Application.DefaultFilePath & "\"
        .Title = "Select a folder..."
        .Show
        MyFolder = .SelectedItems(1) & "\"
    End With
  
    FName = MyFolder & ThisWorkbook.Name
    ThisWorkbook.SaveAs Filename:=FName
End Sub
 
Upvote 0
Application.GetSaveAsFileName will do that nicely.
Code:
Sub triall()
   Dim pathToFolder As String, uiFilePath As String
   
   uiFilePath = Application.GetSaveAsFilename
   If uiFilePath = "False" Then Exit Sub: Rem canceled
   
   pathToFolder = Left(uiFilePath, InStrRev(uiFilePath, Application.PathSeparator))
   
   ThisWorkbook.SaveCopyAs uiFilePath
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top