Share via

Cannot create Excel.Application object from scheduled task

Anonymous
2011-05-03T11:15:17+00:00

Hi,

Under Windows XP I have been using (for years) a VBS script to convert a text file to an Excel spreadsheet from a daily run scheduled task.

The VBS code contains:

Set objExcel = CreateObject("Excel.Application")

Under Windows 7, the scheduled task hangs when run, with wscript.exe displaying the following invisible message box. Because the message box is invisible, no user interaction occurs, causing the hanging situation:

Script: e:\PRIVAT~1\bin\windows\txt2xls.vbs

Line: 17

Char: 1

Error: Permission denied: 'CreateObject'

Code: 800A0046

Source:  Microsoft VBScript runtime error

The scheduled task runs under my (domain) account, and is configured to run whether I'm logged on or not.

How do I allow scheduled tasks to create instances of the Excel COM application object?

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Anonymous
    2011-07-06T20:58:46+00:00

    Here is a workaround that you can try, although it doesn't asnwer the question of why. 

    No programming change is required, but when you create the scheduled task set the Configure for: (on the first screen of the task) to "Windows 2003 Server, Windows XP, Windows 2000".  (Note that you cannot change this setting once the task has been created with the Windows 7 ... setting.)

    Try this and see if it works for you .. it worked for me.

    Actually, after further testing this is not the solution.  While it allows you to submit the scheduled task while logged on and it runs correctly to completion, it still fails when you are not logged in.  It works if you just 'disconnect' from a terminal server session, but not if you have logged off.  So it is not really a viable solution.

    Anyone else with an update?

    Was this answer helpful?

    5 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2014-06-25T21:13:23+00:00

    I had the same problem.  Took me a week to debug and trying to find the source of the problem.  The crazy thing was the same subroutine to create the Excel file is used by multiple functions in the same project.  And I run all these functions from Task Scheduler and only one have problem. 

    After a week of unsuccessfully debugging, I delete the task and set up another one.  The only difference is the task name.  Guess what, it works...

    Hope yours solution is as simple as mine.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  3. Anonymous
    2011-05-03T11:44:15+00:00

    See:

     

    http://www.tech-recipes.com/rx/1839/vista_800a0046_permission_denied_vbscript_runtime_error/

     

     

    I hate to say, but this doesn't fit the bill.

    First of all, my problem is not that the script doesn't run at all. When run manually, it works like a charm, and my account has all required permissions. Only when run from a scheduled task does it fail.

    Furthermore, running the scheduled task as an administrator account requires this account's credentials, something normal users are not provided with in our corporate infrastructure (for obvious reasons).

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2011-05-03T11:39:03+00:00

    Was this answer helpful?

    0 comments No comments