daniels012
Well-known Member
- Joined
- Jan 13, 2005
- Messages
- 5,219
Is there a list of error numbers and their meaning?
Michael
Michael
Code:If Err.Number = 58 Then Range("B11").Value & "l" & ".xls"
ActiveWorkbook.SaveAs Filename:= _
Path & _
Range("B11").Value & ".xls", FileFormat:=xlNormal _
, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
If Err.Number = 58 Then
Path & Range("B11").Value & "l " & ".xls"
new_file = ActiveWorkbook.Name
If Err.Number = 58 Then
Path & Range("B11").Value & "l " & ".xls"
Sub test()
Dim strPath As String, fname As String, i As Integer
strPath = "\\Sidonna\c\Estimating\"
fname = Range("B11") & "*.xls"
With Application.FileSearch
.NewSearch
.LookIn = strPath
.Filename = fname
.Execute
i = .FoundFiles.Count
End With
If i > 0 Then
fname = Range("B11") & i + 1 & ".xls"
x = MsgBox("Your file already exists, do you want to make another copy?", vbYesNo)
Else
fname = Range("B11") & ".xls"
End If
If x = vbYes Or i = 0 Then ActiveWorkbook.SaveAs strPath & fname
End Sub
Dim Path As String, NewFileName As String, i As long
i = 1
Path = "C:\"
NewFileName = Path & Range("B11").Value & ".xls"
'check if the file already exists
Do
'if the file is not found at path specified
If Dir(NewFileName) = "" Then
'exit the loop
Exit Do
Else 'if file already exists at path specified
'add 1 to the file name
' (if filename with '1' on the end exists, will try with 2, etc.)
NewFileName = Path & Range("B11").Value & i & ".xls"
End If
i = i + 1
Loop
'save the file
ActiveWorkbook.SaveAs NewFileName
Dim strPath As String, fname As String, i As Integer
strPath = "\\Sidonna\c\Estimating\"
fname = Range("B11") & "*.xls"
With Application.FileSearch
.NewSearch
.LookIn = strPath
.Filename = fname
.Execute
i = .FoundFiles.Count
End With
If i > 0 Then
fname = Range("B11") & i + 1 & ".xls"
x = MsgBox("Your file already exists, do you want to make another copy?", vbYesNo)
Else
fname = Range("B11") & ".xls"
End If
If x = vbYes Or i = 0 Then ActiveWorkbook.SaveAs strPath & fname