daniels012
Well-known Member
- Joined
- Jan 13, 2005
- Messages
- 5,219
I have this code now:
It works well
IF a file exsists with the same name more than once, it gives a message:
"File Already exsists, would you like to overwrite or cancel"
Is there anyway I can just add a 2, 3, or 4 to the name of the file? Depending on how many files with the same name in Cell B11.
Example would be:
Walter Residence
If it sees a Walter Residence it would then automatically name the next file
Walter Residence 2 then Walter Residence 3 and on and on and on...
Does this make sense?
Thank You for any assistance,
Michael
Code:
Sub SaveToSidonna()
'
' Print_And_Save Macro
'
'
'
Dim strPath As String
Dim wb As Workbook
Application.ScreenUpdating = False
Sheets("ESTIMATING").Select
ActiveWorkbook.Save
Path = "\\Sidonna\c\Estimating\"
'Path2 = "C:\Documents and Settings\Primary User\Desktop\Toms Main\"
ActiveWorkbook.SaveAs Filename:= _
Path & _
Range("B11").Value & ".xls", FileFormat:=xlNormal _
, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
new_file = ActiveWorkbook.Name
Range("F2").Select
'Workbooks.Open Filename:=Path2 & "EstimatingSheetTest.xls"
strPath = "C:\Documents and Settings\Primary User\Desktop\Toms Main\"
If Dir(strPath & "EstimatingSheet.xls") <> "" Then
Set wb = Workbooks.Open(strPath & "EstimatingSheet.xls")
End If
strPath = "C:\Documents and Settings\Owner\My Documents\Daily\"
If Dir(strPath & "EstimatingSheet.xls") <> "" Then
Set wb = Workbooks.Open(strPath & "EstimatingSheet.xls")
End If
Workbooks(new_file).Save
Workbooks(new_file).Close
Application.ScreenUpdating = True
End Sub
It works well



IF a file exsists with the same name more than once, it gives a message:
"File Already exsists, would you like to overwrite or cancel"
Is there anyway I can just add a 2, 3, or 4 to the name of the file? Depending on how many files with the same name in Cell B11.
Example would be:
Walter Residence
If it sees a Walter Residence it would then automatically name the next file
Walter Residence 2 then Walter Residence 3 and on and on and on...
Does this make sense?


Thank You for any assistance,

Michael