troyh68
New Member
- Joined
- Nov 14, 2016
- Messages
- 24
I have created a file from VBA code that will not open after it is created. I found that you have to setup FileFormat in the code to fix this issue however I am now I am getting a compile error (Wrong number of arguments or invalid property assignment) on the SaveCopyAs My code is below. As you can tell I have tried every different combination I can find.
VBA Code:
Sub IncidentReport()
'Save to File Destination
Dim FileName As String
Dim Path As String
'Application.DisplayAlerts = False
FileName = Range("AH2").Value & ".xlsx"
Path = "Z:\TESTING\"
'ActiveWorkbook.SaveCopyAs FileName:="Z:\TESTING\" & Range("AH2").Value & ".xlsx", _
FileFormat:=1, CreateBackup:=False
'ActiveWorkbook.SaveAs FileName:= _
"Z:\SAFETY\Incident Reports\" & FileName, FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
'Application.DisplayAlerts = True
ActiveWorkbook.SaveCopyAs Path & FileName, FileFormat:=xlOpenXMLWorkbook
End Sub