I received this error report from a client, with a very low resolution print. I do not have direct access to the people using the excel file to ask for more details.
I believe the error message says:
Run-time error '1004'
Microsoft Excel cannot access the file 'C:\WINDOWS\System32'. 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 the currently open workbook.
Maybe there is a filename after System32 but I cannot tell for sure. The line that causes the error is shown below:
Public Sub SaveButton()
Dim file As String
Dim answer As Integer
Dim message As String
Dim isXLSM As Boolean
isXLSM = (ActiveWorkbook.FileFormat = xlOpenXMLWorkbookMacroEnabled)
If isXLSM Then
message = "Are you really done? If you confirm, this file will be saved without macros and it won't be possible to edit it further."
Else
message = "Are you really done?"
End If
answer = MsgBox(message, vbYesNo + vbQuestion, "Send to AskHR")
If answer = vbYes Then
If isXLSM Then
Call OnClose
file = SaveXlsx()
Else
ActiveWorkbook.Save 'Here is where the error ocurred
file = ActiveWorkbook.FullName
End If
Call CreateEmail(file)
End If
End Sub
My hypothesis was that maybe he was opening the file inside a zip, but I tried that and could not reproduce the error. I am not manipulating the name of the file, just returning it and using to attach to a Outlook email.
How would the file end up with this path? What could be the cause of this error?
Edit: possibly the file was opened from a read-only directory, which may have caused the error.