sfile is defined prior to reaching the close statement. The file is open.
Assuming I figure out why, will it error out if the file is not open?
Public Sub Print_Batch_RS()
Application.ScreenUpdating = False
'****Establish the file BatchRecords to put the data into
sfile = MyPath + "\BatchRecords.xls"
If Dir(sfile) <> "" Then 'Checks to see if the file exists
Workbooks(sfile).Close SaveChanges:=True 'Closes file and saves it if it is open
Kill (sfile) 'delete BatchRecords
' ActiveWorkbook.Close True
' closes the active workbook and saves any changes
' Workbooks.Open sfile 'Opens file if it is there.
Else
Set Newbook = Workbooks.Add 'If it is not found, this creates and opens the file.
With Newbook
.Title = "Summary Data for AIM."
.Subject = "Data converted from raw AIM output files."
.Author = "Clark Cummins"
.SaveAs FileName:=sfile
' .Worksheets(1).???
End With
End If
Workbooks.Open sfile 'Opens the new file
Assuming I figure out why, will it error out if the file is not open?
Public Sub Print_Batch_RS()
Application.ScreenUpdating = False
'****Establish the file BatchRecords to put the data into
sfile = MyPath + "\BatchRecords.xls"
If Dir(sfile) <> "" Then 'Checks to see if the file exists
Workbooks(sfile).Close SaveChanges:=True 'Closes file and saves it if it is open
Kill (sfile) 'delete BatchRecords
' ActiveWorkbook.Close True
' closes the active workbook and saves any changes
' Workbooks.Open sfile 'Opens file if it is there.
Else
Set Newbook = Workbooks.Add 'If it is not found, this creates and opens the file.
With Newbook
.Title = "Summary Data for AIM."
.Subject = "Data converted from raw AIM output files."
.Author = "Clark Cummins"
.SaveAs FileName:=sfile
' .Worksheets(1).???
End With
End If
Workbooks.Open sfile 'Opens the new file