Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AtiveXscript failing

Status
Not open for further replies.

mkal

Programmer
Jun 24, 2003
223
US
I have a DTS package with the following activeX script that when run by itself (meaning I right-click on it and choose "Execute") it works fine but when you choose to just click the run button and execute the package as a whole this step fails.

Here's the code:

Function Main()
Dim oExcel, oWorkBook, oSheet1, oSheet2, strFile, strFileOriginal, intErr, strErrDesc
On Error Resume Next
Set oExcel = CreateObject("Excel.Application")
strFile = "\\path\filename.xls"
oExcel.Visible = False
oExcel.DisplayAlerts = False
Set oWorkBook = oExcel.Workbooks.Open(strFile)
Set oSheet1 = oWorkbook.Sheets("Products")
Set oSheet2 = oWorkbook.Sheets("Sheet1")
oSheet1.Move oSheet2
oSheet1.Range("A2").Select
oExcel.ActiveWindow.FreezePanes = True
oExcel.ActiveWorkbook.SaveAs strFile
intErr = Err.Number
strErrDesc = Err.Description
If intErr <> 0 Then
msgbox "Error Number: " & intErr & vbCrLf & "Error Desc: " & strErrDesc, , "Excel Error"
oExcel.Quit
Set oExcel = nothing
Main = DTSTaskExecResult_Failure
Else
oExcel.Quit
Set oExcel = nothing
Main = DTSTaskExecResult_Success
End If
End Function

The error message I get is the following:
ErrorNumber: 424
ErrDescription: Object required

There are other ActiveXScripts that run before this one and they all create instances of Excel with no problems and as I said before if you right-click on the task and choose execute it runs fine.

I thought may be that one of the other Excel tasks may not be finished before this one needs to run so I built a delay into the package to wait 1 minute before executing this task but to no avail.

As always any help is appreciated!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top