Using Excel vba Macro to be run through Windows Schedule TaskExtract data from text and selfdestructSchedule complex Macro(.xlsm) Task on Task SchedulerIs there a way to crack the password on an Excel VBA Project?How can you run an Excel macro through a schedule taskIssue with Task Scheduler launching a taskHow to avoid using Select in Excel VBAWindows Task Scheduler running an Excel VBA scriptWindows Task Scheduler to Run batch file that calls vbscript that runs a macroRun excel VBA only if windows task scheduler opened the fileRun excel scheduled when user logged offTask Scheduler will not run macroWindows Task Manager Schedule VBA Macro to Send An Email Using OutLook Daily Running Manually and Not Automatically
Have I saved too much for retirement so far?
Your magic is very sketchy
Efficiently merge handle parallel feature branches in SFDX
Is there a problem with hiding "forgot password" until it's needed?
Failed to fetch jessie backports repository
Greatest common substring
There is only s̶i̶x̶t̶y one place he can be
Irreducibility of a simple polynomial
Implement the Thanos sorting algorithm
Increase performance creating Mandelbrot set in python
Tiptoe or tiphoof? Adjusting words to better fit fantasy races
Can somebody explain Brexit in a few child-proof sentences?
Where in the Bible does the greeting ("Dominus Vobiscum") used at Mass come from?
Is the destination of a commercial flight important for the pilot?
Will it be accepted, if there is no ''Main Character" stereotype?
Hostile work environment after whistle-blowing on coworker and our boss. What do I do?
Applicability of Single Responsibility Principle
Can a monster with multiattack use this ability if they are missing a limb?
Do I need a multiple entry visa for a trip UK -> Sweden -> UK?
Curses work by shouting - How to avoid collateral damage?
Print name if parameter passed to function
What is the oldest known work of fiction?
Why are on-board computers allowed to change controls without notifying the pilots?
What to do with wrong results in talks?
Using Excel vba Macro to be run through Windows Schedule Task
Extract data from text and selfdestructSchedule complex Macro(.xlsm) Task on Task SchedulerIs there a way to crack the password on an Excel VBA Project?How can you run an Excel macro through a schedule taskIssue with Task Scheduler launching a taskHow to avoid using Select in Excel VBAWindows Task Scheduler running an Excel VBA scriptWindows Task Scheduler to Run batch file that calls vbscript that runs a macroRun excel VBA only if windows task scheduler opened the fileRun excel scheduled when user logged offTask Scheduler will not run macroWindows Task Manager Schedule VBA Macro to Send An Email Using OutLook Daily Running Manually and Not Automatically
I have a Excel spreadsheet which I've set up a timer to run code into a database. If the spreadsheet is open and the time now is the time set within the timeslot then it exports the data into the database
I use this line in both my subroutine and the workbook_open Application.OnTime TimeValue("22:00:00"), "ExportOpenJobs"
This is great for when the spreadsheet is open, but I want to be able to set it through the Windows Schedule task.
I'm using Windows Server 2012 as my host pc and where the file is stored. Within the Task Scheduler I set the Action to Start a program and the Program script to the location and the actual *.xlsm file along with the start time for the Task. I set this task 30seconds before the time within the Excel VBA.
My problem is that the Windows Task Scheduler runs at the time set, after looking at the Task History I can see the Task Started/Completed and Action Started/Completed often taking around 50mins to complete, but when I check the database the Excel VBA hasn't run.
How can I get my Task Scheduler to run the Excel VBA code?
Within the Windows Server do you actually need to have Excel installed, therefore should it be done on another machine?
excel vba excel-vba scheduled-tasks
add a comment |
I have a Excel spreadsheet which I've set up a timer to run code into a database. If the spreadsheet is open and the time now is the time set within the timeslot then it exports the data into the database
I use this line in both my subroutine and the workbook_open Application.OnTime TimeValue("22:00:00"), "ExportOpenJobs"
This is great for when the spreadsheet is open, but I want to be able to set it through the Windows Schedule task.
I'm using Windows Server 2012 as my host pc and where the file is stored. Within the Task Scheduler I set the Action to Start a program and the Program script to the location and the actual *.xlsm file along with the start time for the Task. I set this task 30seconds before the time within the Excel VBA.
My problem is that the Windows Task Scheduler runs at the time set, after looking at the Task History I can see the Task Started/Completed and Action Started/Completed often taking around 50mins to complete, but when I check the database the Excel VBA hasn't run.
How can I get my Task Scheduler to run the Excel VBA code?
Within the Windows Server do you actually need to have Excel installed, therefore should it be done on another machine?
excel vba excel-vba scheduled-tasks
add a comment |
I have a Excel spreadsheet which I've set up a timer to run code into a database. If the spreadsheet is open and the time now is the time set within the timeslot then it exports the data into the database
I use this line in both my subroutine and the workbook_open Application.OnTime TimeValue("22:00:00"), "ExportOpenJobs"
This is great for when the spreadsheet is open, but I want to be able to set it through the Windows Schedule task.
I'm using Windows Server 2012 as my host pc and where the file is stored. Within the Task Scheduler I set the Action to Start a program and the Program script to the location and the actual *.xlsm file along with the start time for the Task. I set this task 30seconds before the time within the Excel VBA.
My problem is that the Windows Task Scheduler runs at the time set, after looking at the Task History I can see the Task Started/Completed and Action Started/Completed often taking around 50mins to complete, but when I check the database the Excel VBA hasn't run.
How can I get my Task Scheduler to run the Excel VBA code?
Within the Windows Server do you actually need to have Excel installed, therefore should it be done on another machine?
excel vba excel-vba scheduled-tasks
I have a Excel spreadsheet which I've set up a timer to run code into a database. If the spreadsheet is open and the time now is the time set within the timeslot then it exports the data into the database
I use this line in both my subroutine and the workbook_open Application.OnTime TimeValue("22:00:00"), "ExportOpenJobs"
This is great for when the spreadsheet is open, but I want to be able to set it through the Windows Schedule task.
I'm using Windows Server 2012 as my host pc and where the file is stored. Within the Task Scheduler I set the Action to Start a program and the Program script to the location and the actual *.xlsm file along with the start time for the Task. I set this task 30seconds before the time within the Excel VBA.
My problem is that the Windows Task Scheduler runs at the time set, after looking at the Task History I can see the Task Started/Completed and Action Started/Completed often taking around 50mins to complete, but when I check the database the Excel VBA hasn't run.
How can I get my Task Scheduler to run the Excel VBA code?
Within the Windows Server do you actually need to have Excel installed, therefore should it be done on another machine?
excel vba excel-vba scheduled-tasks
excel vba excel-vba scheduled-tasks
asked Jun 9 '14 at 21:47
JezJez
1621219
1621219
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Hello what I would do is create this .VBS file and then use Windows Task Scheduler to execute this vbs file at the desired interval.
Set fso = CreateObject("Scripting.FileSystemObject")
curDir = fso.GetAbsolutePathName(".")
Set myxlApplication = CreateObject("Excel.Application")
myxlApplication.Visible = False
Set myWorkBook = myxlApplication.Workbooks.Open( curDir & "myTest.xlsm" ) 'Change to the actual workbook that has the Macro
myWorkBook.Application.Run "Module1.HelloWorld" 'Change to the Module and Macro that contains your macro
myxlApplication.Quit
Application.Run Method (Excel)
This example does require Excel to be installed on to the host running the scheduled task. If that host is a Server or a Desktop computer is your choice.
The Windows Task Scheduler should be done as such for the Action portion of the task:
Action: Start a program
Program/script: C:WindowsSysWOW64cscript.exe
Add arguments (optional): C:Path_to_your_vbsYour.vbs
Start in (optional): C:Path_to_your_vbs
Thanks for this, what should I create this through? Visual Studio or similar?
– Jez
Jun 9 '14 at 22:42
Ignore previous comment, I googled it. So with setting the macro to run in this code I wouldn't need to use the Application.On Time event then?
– Jez
Jun 9 '14 at 22:50
That is correct in this case the VBS file is executing the Macro and Windows Task Scheduler is saying when to execute the Macro. The VBS also tells Excel to quit and then the process will start a new when the next event in task scheduler occurs.
– Sean W.
Jun 9 '14 at 22:55
1
The .vbs file can be executed at any time, it does not necessarily need to be executed via Windows Task Scheduler. This script also assumes that the .vbs file is in the same directory as the excel workbook. So in order to troubleshoot the problem you can execute the vbs file at any time and determine what doesn't happen. Does excel open? Does excel open the workbook? Does excel execute the macro? Which step does it fail at?
– Sean W.
Jun 11 '14 at 14:42
1
That is correct the host does need Excel installed on it so if you install excel on the server it will work. The problem with Windows Task Scheduler is that you will actually need to use Action: "Start a Program", Program/script: "C:WindowsSysWOW64cscript.exe", Argument: "C:Path_to_vbsYour.vbs", "Start In: "C:Path_to_vbs". I will update the answer with that as well.
– Sean W.
Jun 11 '14 at 16:27
|
show 9 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f24129613%2fusing-excel-vba-macro-to-be-run-through-windows-schedule-task%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Hello what I would do is create this .VBS file and then use Windows Task Scheduler to execute this vbs file at the desired interval.
Set fso = CreateObject("Scripting.FileSystemObject")
curDir = fso.GetAbsolutePathName(".")
Set myxlApplication = CreateObject("Excel.Application")
myxlApplication.Visible = False
Set myWorkBook = myxlApplication.Workbooks.Open( curDir & "myTest.xlsm" ) 'Change to the actual workbook that has the Macro
myWorkBook.Application.Run "Module1.HelloWorld" 'Change to the Module and Macro that contains your macro
myxlApplication.Quit
Application.Run Method (Excel)
This example does require Excel to be installed on to the host running the scheduled task. If that host is a Server or a Desktop computer is your choice.
The Windows Task Scheduler should be done as such for the Action portion of the task:
Action: Start a program
Program/script: C:WindowsSysWOW64cscript.exe
Add arguments (optional): C:Path_to_your_vbsYour.vbs
Start in (optional): C:Path_to_your_vbs
Thanks for this, what should I create this through? Visual Studio or similar?
– Jez
Jun 9 '14 at 22:42
Ignore previous comment, I googled it. So with setting the macro to run in this code I wouldn't need to use the Application.On Time event then?
– Jez
Jun 9 '14 at 22:50
That is correct in this case the VBS file is executing the Macro and Windows Task Scheduler is saying when to execute the Macro. The VBS also tells Excel to quit and then the process will start a new when the next event in task scheduler occurs.
– Sean W.
Jun 9 '14 at 22:55
1
The .vbs file can be executed at any time, it does not necessarily need to be executed via Windows Task Scheduler. This script also assumes that the .vbs file is in the same directory as the excel workbook. So in order to troubleshoot the problem you can execute the vbs file at any time and determine what doesn't happen. Does excel open? Does excel open the workbook? Does excel execute the macro? Which step does it fail at?
– Sean W.
Jun 11 '14 at 14:42
1
That is correct the host does need Excel installed on it so if you install excel on the server it will work. The problem with Windows Task Scheduler is that you will actually need to use Action: "Start a Program", Program/script: "C:WindowsSysWOW64cscript.exe", Argument: "C:Path_to_vbsYour.vbs", "Start In: "C:Path_to_vbs". I will update the answer with that as well.
– Sean W.
Jun 11 '14 at 16:27
|
show 9 more comments
Hello what I would do is create this .VBS file and then use Windows Task Scheduler to execute this vbs file at the desired interval.
Set fso = CreateObject("Scripting.FileSystemObject")
curDir = fso.GetAbsolutePathName(".")
Set myxlApplication = CreateObject("Excel.Application")
myxlApplication.Visible = False
Set myWorkBook = myxlApplication.Workbooks.Open( curDir & "myTest.xlsm" ) 'Change to the actual workbook that has the Macro
myWorkBook.Application.Run "Module1.HelloWorld" 'Change to the Module and Macro that contains your macro
myxlApplication.Quit
Application.Run Method (Excel)
This example does require Excel to be installed on to the host running the scheduled task. If that host is a Server or a Desktop computer is your choice.
The Windows Task Scheduler should be done as such for the Action portion of the task:
Action: Start a program
Program/script: C:WindowsSysWOW64cscript.exe
Add arguments (optional): C:Path_to_your_vbsYour.vbs
Start in (optional): C:Path_to_your_vbs
Thanks for this, what should I create this through? Visual Studio or similar?
– Jez
Jun 9 '14 at 22:42
Ignore previous comment, I googled it. So with setting the macro to run in this code I wouldn't need to use the Application.On Time event then?
– Jez
Jun 9 '14 at 22:50
That is correct in this case the VBS file is executing the Macro and Windows Task Scheduler is saying when to execute the Macro. The VBS also tells Excel to quit and then the process will start a new when the next event in task scheduler occurs.
– Sean W.
Jun 9 '14 at 22:55
1
The .vbs file can be executed at any time, it does not necessarily need to be executed via Windows Task Scheduler. This script also assumes that the .vbs file is in the same directory as the excel workbook. So in order to troubleshoot the problem you can execute the vbs file at any time and determine what doesn't happen. Does excel open? Does excel open the workbook? Does excel execute the macro? Which step does it fail at?
– Sean W.
Jun 11 '14 at 14:42
1
That is correct the host does need Excel installed on it so if you install excel on the server it will work. The problem with Windows Task Scheduler is that you will actually need to use Action: "Start a Program", Program/script: "C:WindowsSysWOW64cscript.exe", Argument: "C:Path_to_vbsYour.vbs", "Start In: "C:Path_to_vbs". I will update the answer with that as well.
– Sean W.
Jun 11 '14 at 16:27
|
show 9 more comments
Hello what I would do is create this .VBS file and then use Windows Task Scheduler to execute this vbs file at the desired interval.
Set fso = CreateObject("Scripting.FileSystemObject")
curDir = fso.GetAbsolutePathName(".")
Set myxlApplication = CreateObject("Excel.Application")
myxlApplication.Visible = False
Set myWorkBook = myxlApplication.Workbooks.Open( curDir & "myTest.xlsm" ) 'Change to the actual workbook that has the Macro
myWorkBook.Application.Run "Module1.HelloWorld" 'Change to the Module and Macro that contains your macro
myxlApplication.Quit
Application.Run Method (Excel)
This example does require Excel to be installed on to the host running the scheduled task. If that host is a Server or a Desktop computer is your choice.
The Windows Task Scheduler should be done as such for the Action portion of the task:
Action: Start a program
Program/script: C:WindowsSysWOW64cscript.exe
Add arguments (optional): C:Path_to_your_vbsYour.vbs
Start in (optional): C:Path_to_your_vbs
Hello what I would do is create this .VBS file and then use Windows Task Scheduler to execute this vbs file at the desired interval.
Set fso = CreateObject("Scripting.FileSystemObject")
curDir = fso.GetAbsolutePathName(".")
Set myxlApplication = CreateObject("Excel.Application")
myxlApplication.Visible = False
Set myWorkBook = myxlApplication.Workbooks.Open( curDir & "myTest.xlsm" ) 'Change to the actual workbook that has the Macro
myWorkBook.Application.Run "Module1.HelloWorld" 'Change to the Module and Macro that contains your macro
myxlApplication.Quit
Application.Run Method (Excel)
This example does require Excel to be installed on to the host running the scheduled task. If that host is a Server or a Desktop computer is your choice.
The Windows Task Scheduler should be done as such for the Action portion of the task:
Action: Start a program
Program/script: C:WindowsSysWOW64cscript.exe
Add arguments (optional): C:Path_to_your_vbsYour.vbs
Start in (optional): C:Path_to_your_vbs
edited Jun 11 '14 at 16:30
answered Jun 9 '14 at 22:31
Sean W.Sean W.
699411
699411
Thanks for this, what should I create this through? Visual Studio or similar?
– Jez
Jun 9 '14 at 22:42
Ignore previous comment, I googled it. So with setting the macro to run in this code I wouldn't need to use the Application.On Time event then?
– Jez
Jun 9 '14 at 22:50
That is correct in this case the VBS file is executing the Macro and Windows Task Scheduler is saying when to execute the Macro. The VBS also tells Excel to quit and then the process will start a new when the next event in task scheduler occurs.
– Sean W.
Jun 9 '14 at 22:55
1
The .vbs file can be executed at any time, it does not necessarily need to be executed via Windows Task Scheduler. This script also assumes that the .vbs file is in the same directory as the excel workbook. So in order to troubleshoot the problem you can execute the vbs file at any time and determine what doesn't happen. Does excel open? Does excel open the workbook? Does excel execute the macro? Which step does it fail at?
– Sean W.
Jun 11 '14 at 14:42
1
That is correct the host does need Excel installed on it so if you install excel on the server it will work. The problem with Windows Task Scheduler is that you will actually need to use Action: "Start a Program", Program/script: "C:WindowsSysWOW64cscript.exe", Argument: "C:Path_to_vbsYour.vbs", "Start In: "C:Path_to_vbs". I will update the answer with that as well.
– Sean W.
Jun 11 '14 at 16:27
|
show 9 more comments
Thanks for this, what should I create this through? Visual Studio or similar?
– Jez
Jun 9 '14 at 22:42
Ignore previous comment, I googled it. So with setting the macro to run in this code I wouldn't need to use the Application.On Time event then?
– Jez
Jun 9 '14 at 22:50
That is correct in this case the VBS file is executing the Macro and Windows Task Scheduler is saying when to execute the Macro. The VBS also tells Excel to quit and then the process will start a new when the next event in task scheduler occurs.
– Sean W.
Jun 9 '14 at 22:55
1
The .vbs file can be executed at any time, it does not necessarily need to be executed via Windows Task Scheduler. This script also assumes that the .vbs file is in the same directory as the excel workbook. So in order to troubleshoot the problem you can execute the vbs file at any time and determine what doesn't happen. Does excel open? Does excel open the workbook? Does excel execute the macro? Which step does it fail at?
– Sean W.
Jun 11 '14 at 14:42
1
That is correct the host does need Excel installed on it so if you install excel on the server it will work. The problem with Windows Task Scheduler is that you will actually need to use Action: "Start a Program", Program/script: "C:WindowsSysWOW64cscript.exe", Argument: "C:Path_to_vbsYour.vbs", "Start In: "C:Path_to_vbs". I will update the answer with that as well.
– Sean W.
Jun 11 '14 at 16:27
Thanks for this, what should I create this through? Visual Studio or similar?
– Jez
Jun 9 '14 at 22:42
Thanks for this, what should I create this through? Visual Studio or similar?
– Jez
Jun 9 '14 at 22:42
Ignore previous comment, I googled it. So with setting the macro to run in this code I wouldn't need to use the Application.On Time event then?
– Jez
Jun 9 '14 at 22:50
Ignore previous comment, I googled it. So with setting the macro to run in this code I wouldn't need to use the Application.On Time event then?
– Jez
Jun 9 '14 at 22:50
That is correct in this case the VBS file is executing the Macro and Windows Task Scheduler is saying when to execute the Macro. The VBS also tells Excel to quit and then the process will start a new when the next event in task scheduler occurs.
– Sean W.
Jun 9 '14 at 22:55
That is correct in this case the VBS file is executing the Macro and Windows Task Scheduler is saying when to execute the Macro. The VBS also tells Excel to quit and then the process will start a new when the next event in task scheduler occurs.
– Sean W.
Jun 9 '14 at 22:55
1
1
The .vbs file can be executed at any time, it does not necessarily need to be executed via Windows Task Scheduler. This script also assumes that the .vbs file is in the same directory as the excel workbook. So in order to troubleshoot the problem you can execute the vbs file at any time and determine what doesn't happen. Does excel open? Does excel open the workbook? Does excel execute the macro? Which step does it fail at?
– Sean W.
Jun 11 '14 at 14:42
The .vbs file can be executed at any time, it does not necessarily need to be executed via Windows Task Scheduler. This script also assumes that the .vbs file is in the same directory as the excel workbook. So in order to troubleshoot the problem you can execute the vbs file at any time and determine what doesn't happen. Does excel open? Does excel open the workbook? Does excel execute the macro? Which step does it fail at?
– Sean W.
Jun 11 '14 at 14:42
1
1
That is correct the host does need Excel installed on it so if you install excel on the server it will work. The problem with Windows Task Scheduler is that you will actually need to use Action: "Start a Program", Program/script: "C:WindowsSysWOW64cscript.exe", Argument: "C:Path_to_vbsYour.vbs", "Start In: "C:Path_to_vbs". I will update the answer with that as well.
– Sean W.
Jun 11 '14 at 16:27
That is correct the host does need Excel installed on it so if you install excel on the server it will work. The problem with Windows Task Scheduler is that you will actually need to use Action: "Start a Program", Program/script: "C:WindowsSysWOW64cscript.exe", Argument: "C:Path_to_vbsYour.vbs", "Start In: "C:Path_to_vbs". I will update the answer with that as well.
– Sean W.
Jun 11 '14 at 16:27
|
show 9 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f24129613%2fusing-excel-vba-macro-to-be-run-through-windows-schedule-task%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown