Set fs = CreateObject("Scripting.FileSystemObject")
Set rootFolder = fs.GetFolder(fs.GetParentFolderName(wscript.ScriptFullName))
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
oExcel.DisplayAlerts = False
oExcel.AskToUpdateLinks = False
oExcel.AlertBeforeOverwriting = False
For Each file in rootFolder.Files
If inStr(file.type, "Excel") > 0 Then
Set oWorkbook = oExcel.Workbooks.Open(file.path)
oWorkbook.RefreshAll
oExcel.CalculateUntilAsyncQueriesDone
oWorkbook.Save
oExcel.ActiveWorkbook.SaveAs "\\hccufile1\public\COVID19\IRS Treasury Refunds\IRS Treasury Refund Report.xlsx"
oWorkbook.Close
Set oWorkbook = Nothing
End If
Next
oExcel.Quit
Set oExcel = Nothing
Dim oFSO, myFolder
Dim xlCSV
myFolder="\\hccufile1\public\IT SYSTEMS\ITS PUBLIC\SQL Querys\IRS Treasury Refund\"
Set oFSO = CreateObject("Scripting.FileSystemObject")
xlCSV = 6 'Excel CSV format enum
Call ConvertAllExcelFiles(myFolder)
Set oFSO = Nothing
Sub ConvertAllExcelFiles(ByVal oFolder)
Dim targetF, oFileList, oFile
Dim oExcel, oWB, oWSH
Set oExcel = CreateObject("Excel.Application")
oExcel.DisplayAlerts = False
Set targetF = oFSO.GetFolder(oFolder)
Set oFileList = targetF.Files
For Each oFile in oFileList
If (Right(oFile.Name, 4) = "xlsx") Then
Set oWB = oExcel.Workbooks.Open(oFile.Path)
For Each oWSH in oWB.Sheets
Call oWSH.SaveAs ("\\hccufile1\public\IT SYSTEMS\ITS PUBLIC\SQL Querys\IRS Treasury Refund\History\IRS Treasury Refund Report_" & Month(Now)&"." & Day(Now)&"." & Year(Now) & ".csv", xlcsv)
Next
Set oWSH = Nothing
Call oWB.Close
Set oWB = Nothing
End If
Next
Set rootFolder = fs.GetFolder(fs.GetParentFolderName(wscript.ScriptFullName))
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
oExcel.DisplayAlerts = False
oExcel.AskToUpdateLinks = False
oExcel.AlertBeforeOverwriting = False
For Each file in rootFolder.Files
If inStr(file.type, "Excel") > 0 Then
Set oWorkbook = oExcel.Workbooks.Open(file.path)
oWorkbook.RefreshAll
oExcel.CalculateUntilAsyncQueriesDone
oWorkbook.Save
oExcel.ActiveWorkbook.SaveAs "\\hccufile1\public\COVID19\IRS Treasury Refunds\IRS Treasury Refund Report.xlsx"
oWorkbook.Close
Set oWorkbook = Nothing
End If
Next
oExcel.Quit
Set oExcel = Nothing
Dim oFSO, myFolder
Dim xlCSV
myFolder="\\hccufile1\public\IT SYSTEMS\ITS PUBLIC\SQL Querys\IRS Treasury Refund\"
Set oFSO = CreateObject("Scripting.FileSystemObject")
xlCSV = 6 'Excel CSV format enum
Call ConvertAllExcelFiles(myFolder)
Set oFSO = Nothing
Sub ConvertAllExcelFiles(ByVal oFolder)
Dim targetF, oFileList, oFile
Dim oExcel, oWB, oWSH
Set oExcel = CreateObject("Excel.Application")
oExcel.DisplayAlerts = False
Set targetF = oFSO.GetFolder(oFolder)
Set oFileList = targetF.Files
For Each oFile in oFileList
If (Right(oFile.Name, 4) = "xlsx") Then
Set oWB = oExcel.Workbooks.Open(oFile.Path)
For Each oWSH in oWB.Sheets
Call oWSH.SaveAs ("\\hccufile1\public\IT SYSTEMS\ITS PUBLIC\SQL Querys\IRS Treasury Refund\History\IRS Treasury Refund Report_" & Month(Now)&"." & Day(Now)&"." & Year(Now) & ".csv", xlcsv)
Next
Set oWSH = Nothing
Call oWB.Close
Set oWB = Nothing
End If
Next