Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to run a scheduled macro and Log Off system???
Hello All,
If anyone can help me I would be eternally grateful. I am running a scheduled task of opening an excel spreadsheet and running an auto macro at a specific time every night in Windows NT. Does anyone know how(or if) I can have that macro, or another, close out the excel program and log off my profile on the computer. Right now I have to leave myself logged in and the task leaves Excel open when it is finished. I tried to put my username and password in the appropriate boxes when I am prompted for it in Task Scheduler, but it doesn't work unless I am logged in. My IT person advises that I can't leave my computer logged on continuously without logging it off periodically. Any suggestions? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to run a scheduled macro and Log Off system???
You can quit Excel with this command: Application.quit
Before quitting be sure to save the workbook. I'm doing the same thing you are and also have some code in the ThisWorkbook BeforeClose event. If you get prompts showing up there, you'll need to do something to recognize this is an auto close command and bypass the save dialog box if it shows up. I'm hoping the .save command below does this for you. Here's my code in my timer routine. Some of it my not be necessary, but it definitely works: If FinalTimerDone Then 'Recognizes you want to quit Application.DisplayAlerts = False 'Stops Save message I think AutoQuit = True 'My Public variable to recognize AutoQuit in BeforeClose event ThisWorkbook.Save Application.Quit End If This is code from my Before_Close event if needed: Private Sub Workbook_BeforeClose(Cancel As Boolean) StopTimer 'Stops current timer. Not needed if quitting Excel If AutoQuit Then Application.DisplayAlerts = False else 'Do something different on normal quit if desired End If End Sub So, I'm not really sure if the DisplayAlerts = False are necessary, but they're in my code and it's working and I'm sure no harm is done by using them. TH On 4/16/04 11:56, in article , "Jules" wrote: Hello All, If anyone can help me I would be eternally grateful. I am running a scheduled task of opening an excel spreadsheet and running an auto macro at a specific time every night in Windows NT. Does anyone know how(or if) I can have that macro, or another, close out the excel program and log off my profile on the computer. Right now I have to leave myself logged in and the task leaves Excel open when it is finished. I tried to put my username and password in the appropriate boxes when I am prompted for it in Task Scheduler, but it doesn't work unless I am logged in. My IT person advises that I can't leave my computer logged on continuously without logging it off periodically. Any suggestions? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Run Excel macro from Scheduled Task | Excel Worksheet Functions | |||
How do I open an Excel file on XP system, saved on a Vista system | Excel Discussion (Misc queries) | |||
Accessing macro from a system by all other nodes on LAN | Excel Discussion (Misc queries) | |||
Create macro to copy data on a scheduled basis | Excel Discussion (Misc queries) | |||
Canceling a Macro that Has Been Scheduled | Excel Programming |