Macro: open save as dialogue, prefill filename and path BUT DO NOT SAVE YET

zach9208

Board Regular
Joined
Dec 15, 2015
Messages
117
I am looking for a macro that will populate the save as dialogue box to a specified file path and with a custom save name based on the cell value of (d4) of sheet2 . I want the user to be able to review one last time and manually click the save button.

In other words, I want the populate the dialogue box first, with the file path I selected pre-populate, along with my selected file name also prepopulated.I have tried everything! Please help.

Code:
Sub Macro1()
Application.Dialogs(xlDialogSaveAs).Show "C:\Users\c755748\Desktop\" & Sheet2.Range("D4") & ".xlsm"
End Sub
 
Rereading this, it sounds confusing.
With subfolder:
Code:
Sub Macro1()
Dim wbPath As String
wbPath = ThisWorkbook.Path
If Not Right(wbPath, 1) = "\" Then wbPath = wbPath & "\"
[COLOR=#ff0000]wbPath = wbPath & "SubFolder\"[/COLOR]
Application.Dialogs(xlDialogSaveAs).Show wbPath & Sheet2.Range("D4") & ".xlsm"
End Sub
 
Upvote 0
Obviously, you have to know if the path is a UNC path or a virtual path. We can't guess for you.

If virtual path, means a UNC path was assigned a drive letter:
Code:
Sub Main()
  Dim dt As String, fn As Variant
  dt = "u:\Department1\Invoices\" 'example virtual path with subfolders.
  fn = Application.GetSaveAsFilename(dt & Sheet2.Range("D4").Value & ".xlsm", _
     fileFilter:="Excel Marcro-Enabled Workbook (*.xlsm),*.xlsm")
  MsgBox fn
End Sub

You can find the path if you navigate and copy the Address bar in Explorer, Win+E.
 
Upvote 0
Why don't you see what the path is for yourself. Save it manually in the correct folder and then open that saved document. In the immediate window type
?ThisWorkbooth.Path
That will be where you want to save it.
 
Upvote 0

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