Insert control for user to choose save location

spacebouncer

Board Regular
Joined
Feb 7, 2014
Messages
109
Hi. My program's creating some sheets and saving as pdfs. Happy with that part. I'd like to insert a control to allow the user to set the save location. Is it possible to insert a control like this? Hoping I could get one that works in the usual Microsoft way to allow them to easily choose a folder to save to. Thanks!
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
You could try either this, which actualy saves the Active Workbook in the specified location
Code:
If Application.Dialogs(xlDialogSaveAs).Show Then
    MsgBox "saved"
Else
    MsgBox "cancled"
End If

or you could use this, which returns a file path, that you would use in an explicit .Save statement
Code:
Dim uiFilePath As String

uiFilePath = Application.GetSaveAsFilename
If uiFilePath = "False" Then
    MsgBox "canceled"
Else
    MsgBox "save to " & uiFilePath
End If
 
Upvote 0
Hi Mike. Thanks.

Its the chosen path that I'll want to use later so I'll go with something like below, and write the path into a textbox. For each pdf produced from the data I'll save using this path. Thanks both, it would have taken me a long time to find this.

Code:
Sub ChooseSaveFolder()

With Application.FileDialog(msoFileDialogFolderPicker)
        If .Show = -1 Then ActiveSheet.TextBox1.Value = .SelectedItems(1)
End With

End Sub
 
Upvote 0

Forum statistics

Threads
1,213,551
Messages
6,114,272
Members
448,558
Latest member
aivin

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