I'm trying to automate excel to run a macro contained inside a workbook. From reading various threads, it seems that this should be simple to do using windows task scheduler and VBscript.
However, what seems to be throwing a wrench into the mix is that I have both Excel 2010 and Excel 2003 installed on this machine, Excel 2003 is in the default location. This file however, needs to be run in Excel 2010 (too big). My first issue was that using Set objExcel = CreateObject("Excel.Application") would launch 2003, and I was unable to change this behaviour using regserver. However, I was able to get the file to open in 2010 by using GetObject.
The problem now is, when I run it, I get an error message saying that the Macro may not be available or all Macros are disabled. I've set Excel to allow all macros, and added the location to the trusted location.
Set objExcel = GetObject("D:\myfile.xlsm")
objExcel.Application.Visible = True
objExcel.Application.Run ("CreateRepotversion2()")
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
WScript.Echo "Finished."
However, what seems to be throwing a wrench into the mix is that I have both Excel 2010 and Excel 2003 installed on this machine, Excel 2003 is in the default location. This file however, needs to be run in Excel 2010 (too big). My first issue was that using Set objExcel = CreateObject("Excel.Application") would launch 2003, and I was unable to change this behaviour using regserver. However, I was able to get the file to open in 2010 by using GetObject.
The problem now is, when I run it, I get an error message saying that the Macro may not be available or all Macros are disabled. I've set Excel to allow all macros, and added the location to the trusted location.
Set objExcel = GetObject("D:\myfile.xlsm")
objExcel.Application.Visible = True
objExcel.Application.Run ("CreateRepotversion2()")
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
WScript.Echo "Finished."