Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running Excel macro when not logged into Workstation

Status
Not open for further replies.

mcoko

Technical User
Nov 19, 2002
9
0
0
US
Ok I know this has been sort of covered but none of the other threads answered my quesitons. Thank you in advance for reading this questions, it is kind of long.

I have a macro that I need to run daily when no one is logged on to the workstation (Windows 2000/Windows NT both OS's). I use the Scheduler tool in "My Computer" to open an Excel workbook by running the .xls file. This automatically opens the workbook. I use the auto_open sub to run the macro on open. The macro then opens another file, formats the text in the spreadsheet, transfers some data to the original workbook, closes the second file with out saving, saves the orginal file, final closing the Excel app with Application.Quit.

Now the macro runs fine if I schedule it to run when I am logged on to my Workstation. It opens the file does it's thing and closes the App. The problem is when I tried to run it off line. The task begins, but when I log back on to check if it worked the task is still running. If I was to try and open the file (with out killing the task) I get a message that I am accessing it and would I like to open it read-only. When I kill the app then I can then open the file.

I tried to same thing using a simpler macro (just put "1234" in the first cell) and it opens the file, adds the data, savs it but the task was still running when I logged in.

Does anyone know if what I am trying with the more advanced macro is possible, if so what can I do to make it work. Thank you again for read this long explaination and thanks for any help you can give.
 
Can you figure out how far in your code it got? Can you get back to the VBE after logging back in? To debug, it may be helpful to write info to a text file at various locations, so you can check the progression of the macro after the fact.
Rob
[flowerface]
 
Cool the master replied to my Q. Thanks

No I can't get back into VBE. The task is running in Task Manager but I can not switch to or access. I can kill task in Task Manager or by ending it in the Scheduler.

The simple code I use is this:

Sub auto_open()
ActiveCell.FormulaR1C1 = "1234"
Range("A2").Select
ActiveWorkbook.Save
Application.Quit

End Sub

The Workbook is saved because when I kill it the data has been populated. So it either gets hung up on the Application.quit statement or it can not end the task. Either way that is where I am stuck. Thanks.

(If your wondering I can tell if the data has been populated by the scheduled macro, not when I open to check, because I break the macro as soon as it opens, and if I didn't the second cell is the one that would be populated on the second run.)
 
Sounds like you've pretty much narrowed it down. Not something I've ever run into. What happens if you don't include the quit? (My curiosity speaking, more than anything)
Rob
[flowerface]
 
The same thing happens. It gets hung up. I thought that maybe that was the issue (not quiting Excel and leaving the process running beind the scenes, which is an issue) but when I included the quit statement the same thing happened.

I still have the problem with the quit. Thanks.

 
Does anyone know about this issue. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top