Answer the question
In order to leave comments, you need to log in
How to fix an error when starting a vbs file with the Task Scheduler?
I run the vbs file through the scheduler on windows 10. Vbs without the scheduler opens everything perfectly, opening the file with it gives the following error:
Failed to get property "getScrollTop" of a link whose value is undefined or NULL
Call Run_macros
'запуск макроса'
Sub Run_macros()
'запускаем Excel-процесс
set objExcel = CreateObject ("Excel.Application")
objExcel.Visible = true
Op_writ="R:\ЭКСЕЛЬ\файл1"
objExcel.Workbooks.Open (Op_writ)
'запуск макроса
objExcel.run "ОБН_данных"
'сохранение файла
objExcel.Workbooks("файл1.xlsm").Save
'по завершению закрываем документ. Пишем только имя файла, без пути
objExcel.Workbooks("файл1.xlsm").Close(false)
'закрываем Excel-процесс
objExcel.Quit
end sub
Answer the question
In order to leave comments, you need to log in
In the process of correspondence (in the next answer) and experimentally, it turned out that the reason for the incorrect work was the "phantom" Excel process that remained in memory and did not end after the script was executed. Therefore the error also was shown from the second time of execution.
the probable reason that the process remained hanging is that the script is not correct in some way.
Apparently, some object remains in memory, which prevents the Excel process from completing correctly.
There are two solutions:
1) try to make the correct script. This is correct, but cold.
The last option is attached, but it still did not work correctly.
Call Run_macros
Sub Run_macros()
Dim objExcel
Dim Op_writ
Dim Wb
'запускаем Excel-процесс
Set objExcel = CreateObject ("Excel.Application")
objExcel.Visible = true
Op_writ="R:\инста\ЭКСЕЛЬ\АНАЛИЗ\НОВЫЙПОДПИСЧИКИ17"
Set Wb = objExcel.Workbooks.Open (Op_writ)
'запуск макроса
objExcel.run "ОБН_данных"
'сохранение файла
objExcel.Workbooks("НОВЫЙПОДПИСЧИКИ17.xlsm").Save
'по завершению закрываем документ. Пишем только имя файла, без пути
objExcel.Workbooks("НОВЫЙПОДПИСЧИКИ17.xlsm").Close(false)
'закрываем Excel-процесс
objExcel.Quit
Set objExcel = Nothing
Set Wb = Nothing
End Sub
Most likely, the macro is designed to run in graphical mode and cannot work with an ActiveX component - some of the parameters simply do not exist - hence the error. Rewrite without getScrollTop and the like, or add a pre-execution check. The probable cause is that the scheduler starts in a mode without access to the graphics subsystem.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question