Pre Populate saveas dialogue

fialko

New Member
Joined
Jul 17, 2011
Messages
4
I use a spreadsheet at work that autosaves a copy of a spreadsheet using certain cells and current date to a default location.

There is an issue where for some unknown reason the saved file occasionally saves to some random folder working back down the network folder path or the users My Documents.

To get around this i would like the save as options to show when user presses save button with relevant name format already populated (just so they can see if it saving in right location)

Example

In the worksheet Sheet1 the cells B2, B3 & B5 and todays date would be the save name e.g. B2 = John B3 = Smith (b5 = BS then todays date in format dd/mm/yy)

Could anyone help please?





Thanks
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try this. Put the code in the ThisWorkbook module.
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

    Static saving As Boolean
    Dim saveAsFileName As Variant
 
    If saving Then Exit Sub
 
    saveAsFileName = Sheets("Sheet1").Range("B2").Value & " " & Sheets("Sheet1").Range("B3").Value & " " & Sheets("Sheet1").Range("B5").Value & " " & Format(Now, "mm-dd-yyyy")
    saveAsFileName = Application.GetSaveAsFilename(InitialFileName:=saveAsFileName, FileFilter:="Microsoft Office Excel Workbook (*.xls), *.xls")
    If saveAsFileName <> False Then
        saving = True
        ActiveWorkbook.SaveAs fileName:=saveAsFileName
        saving = False
    End If
    Cancel = True

End Sub
PS - the slash is an invalid character in a file name so I've used hyphens in the date.
 
Upvote 0
Hi John

Thank you so much. Works perfectly and will solve the problem of losing random files

Much appreciated

Barry
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,834
Members
452,947
Latest member
Gerry_F

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