Hi,
I have a script that opens Excel, inserts some data in specific cells and then saves the spreadsheet as the date. Everything works fine, but when I am shutting down my PC at the end of the day, there is a lingering Book1 file open on my PC, since I saved the file as something different. Is there a way to close this file as well within the script. I inserted 2 objExcel.Quit statements at the end of the script and that did not work. Any ideas?
Code snippet:
I have a script that opens Excel, inserts some data in specific cells and then saves the spreadsheet as the date. Everything works fine, but when I am shutting down my PC at the end of the day, there is a lingering Book1 file open on my PC, since I saved the file as something different. Is there a way to close this file as well within the script. I inserted 2 objExcel.Quit statements at the end of the script and that did not work. Any ideas?
Code snippet:
Code:
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Add
' ! Prompt for the Project Number
' !
Wscript.Echo " "
Wscript.StdOut.Write " Project Number: "
ProjNumber = Wscript.StdIn.ReadLine
objExcel.Cells(8, 1).Value = "Project Number:"
objExcel.Cells(8, 2).Value = ProjNumber
objExcel.DisplayAlerts = False
dtmDate = Date
strMonth = Month(Date)
strDay = Day(Date)
strYear = Right(Year(Date),2)
strFileName = "C:\temp\" & "Project_" & ProjNumber & "_" & strMonth & "-" & strDay & "-" & strYear & ".xls"
objWorkbook.SaveAs(strFileName)
objExcel.Quit
objExcel.Quit
Last edited by a moderator: