MS Access and Window scheduled task

M

March

Dear All,

I try to work on Window scheduled task with MS Access. I setup MS Access
closes when it has run for 2 minutes (for example). I use Autoexec to run all
the macros in MS Access. It works well without any problem. However, at the
end when the scheduled task suppose to be done. I have got an error that show
below.

"Microsoft Office Access has encountered a problem and needs to close."

It's simply msgbox that send error report or don't send.

I have no idea how to deal with this. I have read other Q/A about auto close
MS Access doesn't exist as MS Excel does.


Please give me suggestion.


March
 
J

John W. Vinson

I try to work on Window scheduled task with MS Access. I setup MS Access
closes when it has run for 2 minutes (for example). I use Autoexec to run all
the macros in MS Access. It works well without any problem. However, at the
end when the scheduled task suppose to be done.

I'd just put a step Application.Quit at the end of the last macro. No need to
use timer hacks.
 
M

March

Thanks .... this way works for me too... however, I do not need to place in
the last macro through my process for some reason... anyways, it works.
 
M

March

Can I use the code in Excel?

I try the code below. It doesn't work.

dim excelApp
set excelApp = createObject("Excel.Application")
excelApp.workbooks.Open("C:\myDir\xBook.xls")

excelApp.Quit
set excelApp = nothing

Does anything need to be changed?


March
 
A

Albert D. Kallal

March said:
Can I use the code in Excel?

I try the code below. It doesn't work.

dim excelApp
set excelApp = createObject("Excel.Application")
excelApp.workbooks.Open("C:\myDir\xBook.xls")

excelApp.Quit
set excelApp = nothing

Does anything need to be changed?

The above looks correct. The above code will:

launches a copy of Excel
Then opens a Excel document called xbook.xls
Then on the next line you execute a command to quit excel.

So, that code so far looks 100% correct. In my example, or your above
example I have to assume you going to put some code in the middle part that
does something useful. In other words we have:

launch excel
open workbook

I then assume you going to place some useful code in here

quit excel

You might want to explain what it is your trying to do here, but your posted
code should launch excel...and then your code shutdown excel. What your code
going to do in the middle part is up to you.......
 
A

a a r o n . k e m p f

SQL Server has this functionality built in.
It is called 'SQL Agent'.

MSDE supports this in the free version of SQL Server.

Scheduling a vbscript file.. to launch and run some TSQL is just plain
trivial if you had a real database
 
M

March

I got it work well so far. (I rewrite the script again the same as I
posted.) Thank you so much.
 
M

March

I have another question about the script.

To work with the Window Scheduled Task, as you see my code at the end I have
Quit the app and set app = nothing, how come when I check the Window Task
Manager; it still has excel.exe run in the process. This causes me when I run
my vbScript.

Refer to above, my question is how to kill excel.exe in window task manager
within the script before the script runs to open any excel workbooks in my
code.


I have test my script many time, I have found that if my com doesn't
excel.exe run, all my script run smooth without any problem.


I'm very happy that I got you help. I have learn my new lesson on VBScript
now.


Thank you so much.

March
 
A

Albert D. Kallal

dim excelApp
set excelApp = createObject("Excel.Application")
excelApp.workbooks.Open("C:\altry1.xls")
excelapp.visible = true
excelApp.Quit
set excelApp = nothing


I just tested the above, and excel shuts down correctly. Now of couse, the
above script does not do anything usefull.....

You might want to post what "real work" your above script does. If you run
the above script, you just see excel load...and then quit right away.

in testing, the above did not leave a copy of excel running.....

I suspect if your code modifyes the workbook, then you have to run code to
save it, else when you execute a "quit", it then prompting the user to "do
you want to save". Of couse, since there is no way for the user to answer to
that dialog, then excel remains running..

I would suggeest that you modify the above to:

dim excelApp
set excelApp = createObject("Excel.Application")
excelApp.workbooks.Open("C:\altry1.xls")
excelapp.visible = true
' excelApp.Quit
' set excelApp = nothing

Note How I placed a visible = true, and I put ' in front of the last two
lines......

This way, you can run your script..but DURING TESTING YOU will have to shut
down excel. If ANY prompts occur during the shutdown, then you have to
modify your code to PREVENT any prompt (because there will be no one at the
keyboard to answer those prompts). Hence, you must do a LOT of testing to
ensure this will work then no one is present in front of the computer....

After you get your script working without any prompts (when you close
Excel), then you can remove the ' on the last two lines (and, it also likely
a good idea to remove the .visible so you don't actually see excel launch
and run on the computer either....
 
M

March

Dear Albert ,

I reply this message again because of my previous question about kill
process. Now I applied the code to my vbScript. I got it work well.


Again thank you so much for your help. I have learned many thing through
this conversation.


March
 
A

Albert D. Kallal

March said:
Dear Albert ,

I reply this message again because of my previous question about kill
process. Now I applied the code to my vbScript. I got it work well.


Again thank you so much for your help. I have learned many thing through
this conversation.

You should note have to terminate that Excel task, as it means your
code/script is not shutting down excel correctly. I mean to stop a car, we
don't take out a gun and shoot out the tires. (you step on the breaks).

While killing the Excel task may work, it simply means that your script has
some error or problem that is preventing Excel from gracefully shutting down
correctly. Blowing excel out by terminating the task is a possible solution,
but should only be done after you spent some time figuring out why your
script is not shutting down excel.

It not a huge deal, but something is preventing Excel from shutdown down
correctly, and killing it is more of a band aid solution, not an ideal
solution.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top