Executing an excel sub in ActiveX task
I am opening an excel file in an ActiveX script task in a DTS package.
After opening the excel application and then the worksheet, I then want to run a subroutine in the worksheet.
Is there a way to execute a subroutine in an excel file by using an AcitveX script?
Thanks.
Here is how I am opening the worksheet.
Function Main()
Dim Excel_Application
Dim Excel_WorkBook
Dim Excel_WorkSheet
Dim iSheetCounter
Dim sFilename
Dim sSheetName
sFilename = "C:\ExcelFile.xls"
sSheetName = "Data"
Set Excel_Application = CreateObject("Excel.Application")
' Open the workbook specified
Set Excel_WorkBook = Excel_Application.Workbooks.Open(sFilename)
Excel_WorkBook.Worksheets(sSheetName).Activate
'I want to call the subroutine here.
Excel_WorkBook.Save
'Clean Up our Excel Objects
Set Excel_WorkSheet = Nothing
Excel_WorkBook.Close
Set Excel_WorkBook = Nothing
Excel_Application.Quit
Set Excel_Application = Nothing
Main = DTSTaskExecResult_Success
End Function
|