Hi,
1. SSIS package runs on desktop with Excel installed on it.
2. I have the Excel macro that refreshes all:
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Ru
Impor
Public
Public Sub Main()
Dim excel As New Microsoft.Office.Interop.E
Dim wb As Microsoft.Office.Interop.E
wb = excel.Workbooks.Open("C:\D
wb.RefreshAll()
wb.Save()
wb.Close()
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
2A. I also need a way to save the file into 2 locations as below (with current YYYYMM in filename) :
TEMPLATE: REPORT YYYYMM.Xls
Final report: G:\...\Report 200903.xls
F:\...\Report 200903.xls
2B. I then also need to save the files as PDF
PDF FILE SAVED AS: (Using Excel 2007's SAVE AS PDF option)
F:\...\Report 200903.pdf
3. I do not know how to Convert that macro from VBA to .Net code. IS THERE A PROGRAM I can use to do this?
4. I tried to copy the macro directly to SSIS Script task and it did not work too well.
I did find a piece of code that was ment to run macros from SSIS:
'===================
strExcelFile = Replace(WScript.ScriptFull
strMacroName = "run_macro"
Set objExcel = CreateObject("Excel.Applic
Set objWB = objExcel.Workbooks.Open(st
objExcel.Visible = True
objWB.Application.Run strMacroName
objWB.Close False
objExcel.Quit
'===================
But I am unsure how I set this up in a SSIS package.
It would be greate if I could get a sample SSIS package that does these tasks.





by: nmcdermaidPosted on 2009-04-27 at 21:22:05ID: 24247574
Yep. You do the following:
1. Install Excel on the server that SSIS is running on (can sometimes be an issue)
2. Record an Excel macro which does what you need it to do (refresh data, Save As etc.)
3. Convert that macro from VBA to .Net code
4. Paste the code into a script task in SSIS
There are some other minor complications but thats the gist of it. I can give you more info if need be.