Edgarvelez
Board Regular
- Joined
- Jun 6, 2019
- Messages
- 197
- Office Version
- 2016
- Platform
- Windows
Hi All,
I am getting the following Error:
Run-Time error '1004'
Microsoft Excel cannot access the file 'C:Users\edgar\Desktop\Working Files\N\A3221E10'.
There are several possible reasons:
The File name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same name as a
I use the code below, in a few other workbooks and never a problem until now.
Little background, I took and existing workbook which also has this code but modified a different code and now
this code is giving me an error, I can run this same exact code on other workbooks and no problem.
I am getting the following Error:
Run-Time error '1004'
Microsoft Excel cannot access the file 'C:Users\edgar\Desktop\Working Files\N\A3221E10'.
There are several possible reasons:
The File name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same name as a
I use the code below, in a few other workbooks and never a problem until now.
Little background, I took and existing workbook which also has this code but modified a different code and now
this code is giving me an error, I can run this same exact code on other workbooks and no problem.
VBA Code:
Sheets("Intake Macro").Select
Range("A1").Select
Dim sh1 As Worksheet, sh2 As Worksheet
Set sh1 = Sheets("Intake Macro")
Set sh2 = Sheets("UpLoad Sheet")
sh2.Select
sh2.Range("A1").Select
Set Fnd = Sheets("Upload Sheet").UsedRange.Find("Total", , , xlWhole, , , False, , False)
If Not Fnd Is Nothing Then Fnd.EntireRow.Delete
sh2.Cells(Rows.Count, 1).End(xlUp).Offset(2, 0).Select
Selection.Font.Bold = True
With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With
ActiveCell.FormulaR1C1 = "X"
ActiveCell.Offset(, 4).Resize(1, 1).Select
ActiveCell.FormulaR1C1 = "TOTAL"
ActiveCell.Offset(, 3).Resize(1, 4).Select
Dim NextRow As Long
NextRow = Range("H" & Rows.Count).End(xlUp).Row + 2
Range("H" & NextRow & ":K" & NextRow).Formula = "=SUM(H2:H" & NextRow - 1 & ")"
sh2.Range("A2").Select
sh1.Select
sh1.Range("A1").Select
Dim fname As String
Dim fpath As String
Dim name As String
Dim ws As Worksheet
fpath = ActiveWorkbook.Path
fname = Range("D14") & " " & Range("D15") & " " & Range("D8") & ".xlsx"
On Error Resume Next
Set ws = ThisWorkbook.Sheets("UPLOAD SHEET")
On Error GoTo 0
If ws Is Nothing Then
MsgBox "sheet doesn't exist"
Exit Sub
End If
Dim msg
If Dir(fpath & "\" & fname) = vbNullString Then
ThisWorkbook.Sheets("UPLOAD SHEET").Copy
ActiveWorkbook.SaveAs Filename:=fpath & "\" & fname
Else
msg = MsgBox(fname & Chr(10) & Chr(10) & "This File Name Already Exists In The Folder!!" & Chr(10) & Chr(10) & _
"Click YES to continue to save and overwrite the file" & Chr(10) & _
"Or NO to to cancel the Save", vbYesNo, "STOP!")
If msg = vbYes Then
Application.DisplayAlerts = False
ThisWorkbook.Sheets("UPLOAD SHEET").Copy
ActiveWorkbook.SaveAs Filename:=fpath & "\" & fname
Application.DisplayAlerts = True
Else
MsgBox "File save cancelled"
End If
End If
End Sub