ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to automating Excel from an SQL Server Script? (https://www.excelbanter.com/excel-programming/399979-how-automating-excel-sql-server-script.html)

al

How to automating Excel from an SQL Server Script?
 
I have an Excel worksheet that is linked to an SQL stored procedure. I have
coded with VBA this worksheet to Open, Update the data from the SQL stored
procedure it is linked to, then copy this data to another worksheet, format
the columns and data, and close both worksheets.

The goal of this is to open, run, and close this Excel worksheet from
commands stored in an SQL script (view, stored procedure, function) that will
be called to run once a month.

Any ideas how to do this? Or is there a better way to do this? Should this
be posted somewhere else (where)?

Thanks ahead of time for your responses, and ideas!!

urkec

How to automating Excel from an SQL Server Script?
 
"Al" wrote:

I have an Excel worksheet that is linked to an SQL stored procedure. I have
coded with VBA this worksheet to Open, Update the data from the SQL stored
procedure it is linked to, then copy this data to another worksheet, format
the columns and data, and close both worksheets.

The goal of this is to open, run, and close this Excel worksheet from
commands stored in an SQL script (view, stored procedure, function) that will
be called to run once a month.

Any ideas how to do this? Or is there a better way to do this? Should this
be posted somewhere else (where)?

Thanks ahead of time for your responses, and ideas!!



You can use sp_OACrate (and simmilar) SQL Server stored procedure to work
with Excel from SQL Server, but I think this is not the easiest way to work
with COM objects (look in SQL Server Books Online for sp_OA* samples and
you'll see what I mean). If you already have VBA code that works, maybe you
can use Scheduled Tasks to run it once a manth from Excel, and avoid using
SQL Server stored procedures at all. (maybe using Workbook.Open event?)

Hope this helps.

--
urkec


All times are GMT +1. The time now is 11:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com