I receive emails containing excel documents and they open as (excel) read only. I run two other macro's to format it, then I want to save and close it (by using the below code).
I get a 1004 error code on line ThisWorkbook.SaveAs rootDir & FileName & ".xlsx" Any suggestions on how to change the code so it saves properly?
Sub CHProIII()
'
' CHProIII Macro
' save as and close file
'
Dim rootDir As String
Dim FileName As String
rootDir = "G:\REBATES\CutlerHammer\CH Pro's\"
rootDir = Replace(rootDir, "@1", Application.UserName)
FileName = ActiveSheet.Range("J3").Value & " " & ActiveSheet.Range("J1").Value & ".xlsx"
ThisWorkbook.SaveAs rootDir & FileName & ".xlsx"
ThisWorkbook.Close
End Sub
I get a 1004 error code on line ThisWorkbook.SaveAs rootDir & FileName & ".xlsx" Any suggestions on how to change the code so it saves properly?
Sub CHProIII()
'
' CHProIII Macro
' save as and close file
'
Dim rootDir As String
Dim FileName As String
rootDir = "G:\REBATES\CutlerHammer\CH Pro's\"
rootDir = Replace(rootDir, "@1", Application.UserName)
FileName = ActiveSheet.Range("J3").Value & " " & ActiveSheet.Range("J1").Value & ".xlsx"
ThisWorkbook.SaveAs rootDir & FileName & ".xlsx"
ThisWorkbook.Close
End Sub