Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Save to Path & Variable file name | Excel Programming | |||
change default file path in Save As dialog box | Excel Programming | |||
get path - save new file - same sub-directory as existing file | Excel Programming | |||
Using a variable string in a file save path | Excel Programming | |||
Save file path in cell | Excel Programming |