I want to run a macro from an Excel file via VBScript, so that I can run that script via Task Scheduler.
That part works, but when it tries to save the file it always asks "File already exists, want to overwrite? Yes, No, Cancel".
While researching, every thread says set DisplayAlerts to False, which I already did but that does not work. If I only use .Save then it saves it to my default Documents Directory - not the sharepoint.
strPath = "\\ecs.zspi.company.de@SSL\DavWWWRoot\Folder\Test.xlsm"
strMacro = "VV.VVImport2" '
Set objApp = CreateObject("Excel.Application")
objApp.Visible = True
objApp.DisplayAlerts = False
objApp.AskToUpdateLinks = False
objApp.AlertBeforeOverwriting = False
objApp.FeatureInstall = msoFeatureInstallNone
Set wbToRun = objApp.Workbooks.Open(strPath)
objApp.Run strMacro
wbToRun.SaveAs "\\ecs.zspi.company.de@SSL\DavWWWRoot\Folder\Test.xlsm"
wbToRun.Close False
objApp.Quit
It should save the file to the original location without alerting. But I always get the Alert Box "File already exists, want to overwrite? Yes, No, Cancel".
wbToRun.Application.DisplayAlerts = False, based on a comment in another thread. - Ron Rosenfeld