Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Problem running script

Author  Topic 

Bill_C
Constraint Violating Yak Guru

299 Posts

Posted - 2011-03-09 : 02:13:32
I have a script (vb) that I use to open up an excel workbook, when I double click the script it opens the excel workbook and runs the macros which are set to auto-run within it Ok.

Now when I try to run the the same script through sql server using xp_cmdshell, the script runs and opens the workbook (I can see this happening in windows explorer), but the macros within the workbook do not run?

I have enabled the macros in excel (enable all macros),
also I have checked the box to 'Trust to the VBA project object model',
also I have set the folder which the xlsm file is in to be a trusted location,
also I have set the activeX settings to 'Enable all controls'

Yet the macros only will run when I double click the vb script file myself!

I am stumped on this and have been stuck on it for days now, can anyone help or suggest where I could get help to resolve this as it needs to be done quickly.


Thanks

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2011-03-09 : 04:57:36
It's not a good idea to run Excel on a SQL Server server (but you probably know this.)

Those settings you made to enable the Excel macro are per user.
When running under xp_cmdshell, the process will run as your SQL Server service account (or proxy).
Try this:
1. logon to the server as the SQL Server service account
2. make the excel setting changes
3. log-off the server
4. and run your script using xp_cmdshell.

Hope this helps
Go to Top of Page

Bill_C
Constraint Violating Yak Guru

299 Posts

Posted - 2011-03-09 : 07:44:53
Thanks, OK now.
Go to Top of Page
   

- Advertisement -