Results 1 to 3 of 3

Thread: ActiveX in a SQL Agent Job

Hybrid View

  1. #1
    Join Date
    Nov 2002
    Location
    DE
    Posts
    246

    ActiveX in a SQL Agent Job

    Hi all,

    I have a problem with a SQL Agent JOB on SQL 2K SP3 installation (on Win2K Server).

    SQL Agent is running under a domain account with local Admin privileges and SA privileges in SQL server.

    A job with an ActiveXScript step fails with "Permission denied: 'CreateObject line..."

    If I execute the same ActiveXScript as cmdexec step (calling CSript with the VBScript as parameter) it works without any problem.

    The ActiveXScript for reference:
    Dim oXls
    Dim oWorkBook
    Dim oSheet

    Set oXLS = CreateObject ("Excel.Application")

    oXls.Visible = True
    oXls.DisplayAlerts = True

    Set oWorkBook = oXLS.WorkBooks.Add
    Set oSheet = oWorkBook.ActiveSheet

    oSheet.Name = "Test AG"

    oWorkBook.SaveAs "C:\Temp\TestAg.Xls"
    oWorkBook.Close

    Set oSheet = Nothing
    Set oWorkBook = Nothing

    oXls.Quit
    Set oXlS = Nothing


    Does anybody have any idea why approach 1 fails while approach 2 does work happily?
    Last edited by andi_g69; 02-22-2005 at 02:59 AM.

  2. #2
    Join Date
    Feb 2003
    Posts
    1,048
    Yep!!

    The problem is that when you execute the job manually, it is running on your local machine. When you execute it via the scheduled job, it is running on the SQL Server machine directly. That error doesn't always mean that permission was denied, it also means that the core object doesn't exist on the server. I'd be willing to bet $5 that Excel isn't installed on the SQL Server.

  3. #3
    Join Date
    Nov 2002
    Location
    DE
    Posts
    246
    Hi Rawhide
    Unfortunately this is not the explanation because:

    1) Excel is installed on the server
    2) Under both scenarios I am using a SQL Agent job, only difference is the first one uses a job step of type ActiveXScript. The second uses a CMDExec job step which fires the VBSript through CSript.exe

    On top of that it does not make any differnece if I start the job manually or through scheduler.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •