harryhoudini66
Technical User
Hello, I need help combining multiple scripts. On their own, each one works. I schedule them to proces via Windows Scheduler. I would prefer to schedule one script instead of three so I am trying to combine them. I am a total newb when it comes to scripts. In fact, some of them I created through the help in these forums or by googling. When I run the script below, I get a message indicating their is an issue with Line 11, character 1. Not sure what the problem may be.
CreateObject("WScript.Shell").Run "\\fileserver2\msc\MSC_Reports\Interval\Scripts\Intervals\Morning_Intervals.acsauto"
Delay 60
Sub Delay( seconds )
Dim wshShell
Set wshShell = CreateObject( "WScript.Shell" )
wshShell.Run "ping -n " & ( seconds + 1 ) & " 127.0.0.1", 0, True
Set wshShell = Nothing
End Sub
Option Explicit
Dim fso, f, sFile, sCSVPath, xl
Dim wb
Set xl = CreateObject("Excel.application")
sCSVPath = "\\fileserver2\MSC\MSC_Reports\Interval\Output"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(sCSVPath)
For Each sFile In f.Files
If UCase(fso.GetExtensionName(sFile.Name)) = "CSV" Then
OpenFileInExcel sFile.Path
End If
Next
OpenFileInExcel "\\fileserver2\MSC\MSC_Reports\Interval\MSCInteReportvWindows_7.xlsx"
'sorry that I missed this...
xl.DisplayAlerts = False
For Each wb In xl.Workbooks
With wb
If UCase(Right(.Name, 3)) <> "CSV" then
.Save
End if
.Close
End With
Next
Sub OpenFileInExcel(sFilename)
Set wb = xl.Application.Workbooks.Open(sFilename)
xl.Application.Visible = True
End Sub
xl.quit
Dim objOutl
Set objOutl = CreateObject("Outlook.Application")
Set objMailItem = objOutl.CreateItem(olMailItem)
objMailItem.Display
strEmailAddr = "mail@mail.com"
objMailItem.Recipients.Add strEmailAddr
objMailItem.Subject = "Interval Report "& Date &" for 7-11"
objMailItem.HTMLBody = "Text"
objMailItem.Attachments.Add "\\fileserver2\MSC\MSC_Reports\Interval\MSCInteReportvWindows_7.xlsx"
objMailItem.Display
Set objMailItem = nothing
Set objOutl = nothing
CreateObject("WScript.Shell").Run "\\fileserver2\msc\MSC_Reports\Interval\Scripts\Intervals\Morning_Intervals.acsauto"
Delay 60
Sub Delay( seconds )
Dim wshShell
Set wshShell = CreateObject( "WScript.Shell" )
wshShell.Run "ping -n " & ( seconds + 1 ) & " 127.0.0.1", 0, True
Set wshShell = Nothing
End Sub
Option Explicit
Dim fso, f, sFile, sCSVPath, xl
Dim wb
Set xl = CreateObject("Excel.application")
sCSVPath = "\\fileserver2\MSC\MSC_Reports\Interval\Output"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(sCSVPath)
For Each sFile In f.Files
If UCase(fso.GetExtensionName(sFile.Name)) = "CSV" Then
OpenFileInExcel sFile.Path
End If
Next
OpenFileInExcel "\\fileserver2\MSC\MSC_Reports\Interval\MSCInteReportvWindows_7.xlsx"
'sorry that I missed this...
xl.DisplayAlerts = False
For Each wb In xl.Workbooks
With wb
If UCase(Right(.Name, 3)) <> "CSV" then
.Save
End if
.Close
End With
Next
Sub OpenFileInExcel(sFilename)
Set wb = xl.Application.Workbooks.Open(sFilename)
xl.Application.Visible = True
End Sub
xl.quit
Dim objOutl
Set objOutl = CreateObject("Outlook.Application")
Set objMailItem = objOutl.CreateItem(olMailItem)
objMailItem.Display
strEmailAddr = "mail@mail.com"
objMailItem.Recipients.Add strEmailAddr
objMailItem.Subject = "Interval Report "& Date &" for 7-11"
objMailItem.HTMLBody = "Text"
objMailItem.Attachments.Add "\\fileserver2\MSC\MSC_Reports\Interval\MSCInteReportvWindows_7.xlsx"
objMailItem.Display
Set objMailItem = nothing
Set objOutl = nothing