sproc calling xp_cmdshell invoking vbs to set column properties in Excel

  • Hi all,

    I'm trying to modify an Excel spreadsheet from SQL Server.

    I have a vbs file which includes line 4,

    Set objExcel = CreateObject("Excel.Application")

    When I run from command prompt or batch file, the vbs executes perfectly, and I am able to set the properties on the columns in the spreadsheet, save the changes, and exit.

    When I try to run from xp_cmdshell, I get an error,

    Update_Spreadsheet.vbs(4, 1) Microsoft VBScript runtime error: ActiveX component can't create object: 'Excel.Application'

    The SQL Server service is running under a domain account which has the same privileges as my own account.

    Any ideas?

    Thanks,

    Paul

  • i think the domain account needs to have launched excel at least once manually on the server itself, right?

    the first time excel launches for a user, if there are not a suite of registry settings for it, it prompts you for your initials with a dialog that cannot be supressed via code;

    The last time i automated excel like that i tripped over that specific situation...do you think that could be what the issue is here? no registry settings under %current_User% for the excel to grab settings from?

    you don't get the error from the command prompt, of course, because you've used excel at least once under your domain login.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Spot on, Lowell.

    I guess it works from the command prompt on my machine since Excel is installed locally. But Excel isn't installed on the server -- and probably should not be.

    Is there a way of enabling this functionality so that it can run from the server?

    I thought about breaking up the tasks into two: creating the files, and then modifying the column properties from a batch file.

    I tried setting up a scheduled task on my station. First time, I got an error.

    I tweaked the registry as per this article http://support.microsoft.com/kb/207574, and it works now. However, this is not the preferred solution.

    Thanks!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply