Error occurs at the "Name sfile as sbfile" line. Is there an object issue? Is there an issue with the use of date and time in the sbfile format?
Public Sub Print_Batch_RS()
Dim sfile As String
Dim sbfile As String
Dim Myfile As String
Dim MyoldFile As String
Dim g
Dim g2
Dim MyDate
Dim MyTime
Application.ScreenUpdating = False
'****Establish the file BatchRecords to put the data into
g = Date
g2 = Time
Myfile = "\BatchRecords.xls"
MyDate = Format(g, "yymmdd")
MyoldFile = "\BtchRcrd_" & MyDate & "_" & g2 & ".xls"
Set sfile = MyPath & Myfile
Set sbfile = MyPath & MyoldFile
If Dir(sfile) <> "" Then 'Checks to see if the file exists
On Error Resume Next
Workbooks("BatchRecords.xls").Close SaveChanges:=True 'Closes file and saves it if it is open
On Error GoTo 0
Name sfile As sbfile 'There is no need to Kill sfile as it no longer exists
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
Public Sub Print_Batch_RS()
Dim sfile As String
Dim sbfile As String
Dim Myfile As String
Dim MyoldFile As String
Dim g
Dim g2
Dim MyDate
Dim MyTime
Application.ScreenUpdating = False
'****Establish the file BatchRecords to put the data into
g = Date
g2 = Time
Myfile = "\BatchRecords.xls"
MyDate = Format(g, "yymmdd")
MyoldFile = "\BtchRcrd_" & MyDate & "_" & g2 & ".xls"
Set sfile = MyPath & Myfile
Set sbfile = MyPath & MyoldFile
If Dir(sfile) <> "" Then 'Checks to see if the file exists
On Error Resume Next
Workbooks("BatchRecords.xls").Close SaveChanges:=True 'Closes file and saves it if it is open
On Error GoTo 0
Name sfile As sbfile 'There is no need to Kill sfile as it no longer exists
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