Microsoft KB Archive/275719

= PRB: Office Applications Fail to Run VBA Code Under Task Scheduler for Windows NT4 Terminal Server =

PSS ID Number: 275719

Article Last Modified on 5/20/2003

-

The information in this article applies to:


 * Microsoft Windows NT Server 4.0 Terminal Server Edition
 * Microsoft Excel 2000
 * Microsoft Excel 97 for Windows
 * Microsoft PowerPoint 97 for Windows
 * Microsoft Word 97 for Windows
 * Microsoft PowerPoint 2000
 * Microsoft Word 2000
 * Microsoft Excel 2002
 * Microsoft PowerPoint 2002
 * Microsoft Word 2002

-



This article was previously published under Q275719



SYMPTOMS
When a task is scheduled on Windows NT4 Terminal Server using the Task Scheduler Service, and the task launches an Office application to run Visual Basic for Applications (VBA) code, the Office application may fail to run the code correctly or may cause Office to stop responding, thus causing the task to fail and leaving the Office app running in memory. The same task stops responding when it is run manually or from Task Scheduler while the user is logged on interactively.



CAUSE
The Task Scheduler allows administrators to specify a user account under which to run the given task. However, for Terminal Server, this setting does not load the proper user settings (registry hive) needed for the task to run. When users who are specified in the setting are logged on interactively, their user settings are loaded under their respective WinStations, and the task runs as expected. However, if they are not logged on, the service creates the needed WinStation but does not load all of the user registry settings. Because Office applications cannot read these user settings, they default to restrictive settings that either prevent macros from running or bring up a dialog box asking the user to enable macros. With no user to dismiss a dialog, the process can hang and task is not finished.

This problem does not occur under Microsoft Windows 2000 Server with Terminal Services installed.



RESOLUTION
If a Microsoft Windows NT-based Service is run by using the same account information as the task, then the proper registry information is loaded and the task can complete successfully. You must use a different service because the NT4 Terminal Server Task Scheduler does not allow you to run the Task Scheduler process under a specific user account (it always runs under the System account).

Developers can explicitly load the registry hive for a user account if it is impractical to configure another service to run.

For additional information about this topic, click the article number below to view the article in the Microsoft Knowledge Base:

168877 HOWTO: Load a User's Hive Programmatically

