troubleshooting Question

Running a Execl macro from vbs via scheduled tasks leaves EXCEL.EXE process running and Excel file as read only.

Avatar of killswitch
killswitch asked on
VB Script
11 Comments1 Solution2636 ViewsLast Modified:
I created a vbs script to open a Excel file which runs a macro and updates the sheets. The vbs script runs fine if you just run it. The Excel file opens the macro runs and the file gets updated and closes. The problem I am encountering is when I run the vbs file from Scheduled Tasks it opens the file, updates the
sheet but it leaves the process EXCEL.EXE running and if you try to open the file it can only open as read only. I have tried putting in a sleep thinking a delay would hlep, and I have looked at user/file permissions. I am using Excel 2000, Access 2000(used in the macro), on a Windows 2003 server.
strFile = "C:\Documents and Settings\srv1admin\My Documents\Sales Reports LonRon\Total pairs by category and brands.xls"
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open _
	("C:\Documents and Settings\srv1admin\My Documents\Sales Reports LonRon\Total pairs by category and brands.xls")
 
objExcel.Visible = True
objExcel.Run("RunAll08")
 
 
'Test save and close below
objExcel.DisplayAlerts = False
objExcel.ActiveWorkbook.SaveAs strFile
 
 
objExcel.DisplayAlerts = False
objExcel.ActiveWorkbook.Close
 
 
objExcel.DisplayAlerts = False
objExcel.Application.Quit
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 11 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros