Microsoft KB Archive/275719

From BetaArchive Wiki
Knowledge Base


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


REFERENCES

Please be aware that the current versions of Office are not designed to run unattended, and while you can run VBA code from the Task Scheduler, it may have side effects that give similar dialog boxes and configuration errors.

For additional information about using Office applications in this manner, click the article number below to view the article in the Microsoft Knowledge Base:

257757 INFO: Considerations for Server-Side Automation of Office


For additional information on a related problem specific to loading Word documents, click the article number below to view the article in the Microsoft Knowledge Base:

224338 PRB: Error 800A175D - Could Not Open Macro Storage


For information on creating a sample NT service, please see the MSDN Library article on the following Microsoft Web site:

Keywords: kbAutomation kbprb kbProgramming KB275719
Technology: kbExcel2000 kbExcel2000Search kbExcel2002 kbExcel2002Search kbExcel97Search kbExcelSearch kbExcelWinSearch kbNTTermServ400 kbNTTermServSearch kbPowerPt2000 kbPowerPt2000Search kbPowerPt2002 kbPowerPt2002Search kbPowerPt97 kbPowerPt97Search kbPowerPtSearch kbWinNT400search kbWinNTS400search kbWinNTsearch kbWinNTSsearch kbWord2000 kbWord2000Search kbWord2002 kbWord2002Search kbWord97 kbWord97Search kbWordSearch kbZNotKeyword2 kbZNotKeyword3