Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Excel macro from Scheduled Task coolthinking Excel Worksheet Functions 4 July 13th 09 03:35 PM
How do I open an Excel file on XP system, saved on a Vista system JLS7 Excel Discussion (Misc queries) 3 December 2nd 08 04:21 AM
Accessing macro from a system by all other nodes on LAN NSNR Excel Discussion (Misc queries) 1 January 28th 08 02:37 PM
Create macro to copy data on a scheduled basis faureman Excel Discussion (Misc queries) 0 January 25th 07 04:25 PM
Canceling a Macro that Has Been Scheduled Murray Williams Excel Programming 2 July 25th 03 11:28 PM


All times are GMT +1. The time now is 10:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"