VBA code not running properly when using Scheduled Tasks

Rayanea

New Member
Joined
Aug 1, 2010
Messages
13
Hello,

I am not sure this is the right place to post my question but I give it a shot.

I have programmed my computer to turn on at 7am every morning, then using windows' Scheduled Tasks, I am opening an excel workbook at 7:05 am. The workbook is programmed to run a vba code on opening. When I wake up around 7:30 am, I am checking what is happening. I am always surprised to see that the code stops running at one moment (I am retrieving data from the web), and it is not always the same stage. I am 110% sure this is not coming from the VBA code, as when I run it manually (i.e. opening myself the workbook by clicking on it), it works perfectly well.

I am wondering if it does not come from windows or the Scheduled Task software.

Does someone has any idea from where it could come and how to solve this issue ?

Thank you very much for your help.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I don't have the answer as I guess that it would be necessary to look at the code and/or what is being done.
However, the best thing to do is to add some diagnostic code, either as 'debug.print' or details written to a worksheet, and each time you run it you can try to narrow the search down to a section or line of code.
 
Upvote 0
Is this to do with your other thread?

I don't know if I suggested, but may have, there that problems with this sort of code could be affected by your internet access/connection etc.

Perhaps when you manually run the code something is happening that doesn't happen when it's run using Scheduler.

How exactly are you running the code anyway?

Workbook open event?
 
Upvote 0
Yes, I am using a Workbook open event.

@Norie: indeed, this is the same code as my other thread. But I am not sure there is a problem with the code.

I thought there was a conflict with other task planned with Scheduled Tasks, but it does not seem to be the case. I will try set the InternetExplorer.Visible to true instead of false to see if it comes from there.

@Derek Brown: how would you insert the debug.print code ? At the end of the loop or every now and then in the code ?

Thanks for your help.
 
Upvote 0
I'm not saying the problem is with the code.

I'm trying to say that it could be something to do with your internet connection/speed/access etc

If you are on a network it could be problems with that.
 
Upvote 0
I would insert something like:
Code:
.
. ' my code here
.
debug.print "Step 1"
.
. ' my code here
.
debug.print "Step 2"
.
.
etc. These would be placed at important parts of the code, within loops if there is code there that is doing something relevant. If within a loop it would be better to include a 'counter' e.g.
Code:
debug.print "Step 5 (" & lngKounter & ")"
lngKounter = lngKounter + 1
In the VBE 'Immediate' window you would see Step 1, Step 2 etc. and then know how far it gets each time.
 
Upvote 0
I tried this morning with the InternetExplorer.Visible = True

When I woke up, I noticed that the program was running, but nothing was progressing (as usual I would say). Interestingly, no IE window was open, and the processor was 100% used. However, I still noticed a iexplorer process in the Windows Task Manager. I am really wondering if there is no conflict with the Google updates scheduled in Task Scheduler.

I guess there is a conflict somewhere, but can't figure out where... I am trying with the debug.print tonight.

Note that I am not on a network.
 
Upvote 0
Hello,

I think I could have figured out where the problem lies and apparently it could have nothing to do with the Task Scheduler.

After having updated my code, I ran it and watched it opening and closing IE windows as it does normally.

On one particular window, the page couldn't load properly. I waited some time but nothing happened. Then I tried a refresh with F5. The page reloaded properly and the code continued to run.

Hence, I am wondering if I should not use the Refresh method for IE application in case the page is still not loaded after a certain amount of time ?

Thank you very much for your feedback.
 
Upvote 0

Forum statistics

Threads
1,213,558
Messages
6,114,297
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top