Code:
'Save the report
msFileName = "STT_Audit_" & Format(mdtStartDate, "yyyymmdd") & "_" & Format(mdtEndDate, "yyyymmdd") & "." & msFormat
sFullFileName = msFilePath & "\" & msFileName
Set fso = New FileSystemObject
If fso.FileExists(sFullFileName) Then fso.DeleteFile (sFullFileName)
If msFormat = "htm" Then
Call oExcel.ActiveWorkbook.PublishObjects.Add(xlSourceSheet, sFullFileName, "Sheet1", "", xlHtmlStatic, , "").Publish(True)
oExcel.ActiveWorkbook.Close (False)
Call oExcel.Quit
Shell "explorer " & sFullFileName, vbMaximizedFocus
Else
oExcel.ActiveWorkbook.SaveAs (sFullFileName)
oExcel.Visible = True
End If
Exit Sub