Hi all, I created an ActiveX inside DTS job package. It runs fine if I execute it manually. If I put inside the SQL Server Agent Jobs Scheduler, it returns an error 'ActiveX component can't create object 'Excel.Application'...
Here's code inside the ActiveX
Thank you,
dk
Here's code inside the ActiveX
Code:
Dim Excel_Application
Dim Excel_WorkBook
Dim Excel_WorkSheet
Dim rRange
Dim sFilename
Dim sSheetName
sFilename = "E:\Temp\US Active.XLS"
sSheetName = "Active"
Set Excel_Application = CreateObject("Excel.Application")
' Open the workbook specified
Set Excel_WorkBook = Excel_Application.Workbooks.Open(sFilename)
For Each Excel_WorkSheet in Excel_WorkBook.WorkSheets
' Find the WorkSheet specified
If Excel_WorkSheet.Name = CStr(sSheetName) Then
Set rRange = Excel_WorkBook.Worksheets(sSheetName).Range("A2:IV65536")
rRange.Delete
Excel_WorkBook.Save
Exit For
End if
Next
'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
Thank you,
dk