ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   file save as (path and custom name) (https://www.excelbanter.com/excel-programming/343384-file-save-path-custom-name.html)

savalou

file save as (path and custom name)
 
Hello,

I would like to write a macro that will save a workbook to a user
provided path and directory with an file name defined via code and
consisting of the original workbook name+textbox1 value+text box 2
value.

Any thoughts?

thanks!

dave


savalou

file save as (path and custom name)
 
Found some code in a previous posting. Almost works. How can I use
the ThisWorkbook.Name property and exclude the .xls extension until the
end?

Thanks!

Dave

Sub BtnSaveAs()
Dim Suggest, res, Fname, Hdr, Fs
Application.DisplayAlerts = False
Suggest = RTrim(ThisWorkbook.Name, 4) & "-" &
Sheets("data").Range("A31").Value & "-" &
Sheets("data").Range("A30").Value
Hdr = "Please choose a Destination for the Copy, give it a name then
click save"
GetFname: Fname = Application.GetSaveAsFilename(Suggest,
fileFilter:="Excel File(*.xls), *.xls)", Title:=Hdr)
If Not Fname = False Then
Set Fs = CreateObject("Scripting.FileSystemObject")
If Fs.FileExists(Fname) Or Fs.FileExists(Fname & ".xls") Then
res = MsgBox(Fname & " already exists." _
& " Do you want to replace it?", vbYesNo, "Duplicate")
If res = vbNo Then GoTo GetFname:
End If
ThisWorkbook.SaveAs Fname
End If
Xit:
Application.DisplayAlerts = True
End Sub



All times are GMT +1. The time now is 08:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com