Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I want to change the name of my file "Estimation File" to "Master
File" when I save it to (or if it's already in) my C drive. Sheet1!A1 has a formula that returns either 0 or 1. Following are the conditions: If Sheet1!A1 = 0 and file is in C drive, then no change to file name If Sheet1!A1 = 1 and file is in C drive, then change file name to "Master File" Chane occurs only when the file is saved in/to C drive Thanks for any solution you might have. Michael |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Oct 2, 12:41*pm, Michael Lanier wrote:
I want to change the name of my file "Estimation File" to "Master File" when I save it to (or if it's already in) my C drive. *Sheet1!A1 has a formula that returns either 0 or 1. *Following are the conditions: If Sheet1!A1 = 0 and file is in C drive, then no change to file name If Sheet1!A1 = 1 and file is in C drive, then change file name to "Master File" Chane occurs only when the file is saved in/to C drive Thanks for any solution you might have. Michael Try this. I left in the "ask if overwrite" on purpose Sub savefile() If Sheets("Sheet1").Range("a1") = 1 Then fn = "Master File.xls" Else fn = ThisWorkbook.Name End If ActiveWorkbook.SaveAs Filename:=fn, FileFormat:= _ xlNormal, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Don,
Thanks for your help. I modified your suggestion as follows: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) If Sheets("Sheet1").Range("a1") = 1 Then fn = "Master File.xls" Else fn = ThisWorkbook.Name End If ActiveWorkbook.SaveAs Filename:=fn, FileFormat:= _ xlNormal, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False End Sub I placed it in ThisWorkbook. It changes the file name as expected, but then I get a popup that states "Excel has stopped working . . ." I'm still a novice so the problem is probably obvious to you. Also, I'm using 2003 if that makes a difference but I also run it as a compatible in my 2007 on occasion. Thanks in advance if you have any further suggestions. Michael |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel file gets corrupt if saved in one particular drive | Excel Discussion (Misc queries) | |||
Hyperlinks change when file is saved | Excel Worksheet Functions | |||
Links to mapped drive change to refer to local hard drive | Links and Linking in Excel | |||
Combobox Change Event when file is saved as | Excel Programming | |||
Find links with code; change from G drive to C drive | Excel Programming |