dbTalk Databases Forums  

Exit from Excel Sheet loop

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Exit from Excel Sheet loop in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Leo
 
Posts: n/a

Default Exit from Excel Sheet loop - 10-10-2003 , 09:32 AM






Hi
I am sure if this is possible.. I am trying to call an
ActiveX script based on the number of sheets in an Excel
File. The stpEnterLoop.ExecutionStatus =
DTSStepExecStat_Waiting
doesn't seem to be working within an Excel sheet loop..
Is there anything i am doing wrong or it is not possible
at all to execute another task from a loop in a dts
package.

Thanks for your help
Thanks
L



Option Explicit

Function Main()

Dim sActualLocationOfData
Dim Excel_Application
Dim Excel_WorkBook
Dim Excel_WorkSheet
Dim oPkg
Dim oConn
Dim bfound
Dim iSheetCounter
Dim SheetName

dim pkg
dim conTextFile
dim stpEnterLoop
dim stpEndLoop

set pkg = DTSGlobalVariables.Parent

sActualLocationOfData = "=Sales" & CStr
(DTSGlobalVariables("SheetNumber").Value) & "!" &
DTSGlobalVariables("DataLocation").Value

Set Excel_Application = CreateObject
("Excel.Application")

Set Excel_WorkBook =
Excel_Application.Workbooks.Open(DTSGlobalVariable s
("FileLocation").Value)


iSheetCounter = Excel_WorkBook.WorkSheets.Count

set stpEnterLoop = pkg.Steps
("DTSStep_DTSActiveScriptTask_3")

set stpEndLoop = pkg.Steps
("DTSStep_DTSActiveScriptTask_2")

if iSheetCounter > 0 then
For Each Excel_WorkSheet in
Excel_Workbook.WorkSheets

sActualLocationOfData = "="
&Excel_WorkSheet.Name & "!" & DTSGlobalVariables
("DataLocation").Value

msgbox sActualLocationOfData

stpEnterLoop.DisableStep = False

stpEnterLoop.ExecutionStatus =
DTSStepExecStat_Waiting

stpEndloop.DisableStep = True

Next

stpEndLoop.DisableStep = False
stpEndLoop.ExecutionStatus =
DTSStepExecStat_Waiting
stpEnterLoop.DisableStep = True
End If

Excel_WorkBook.Save

Excel_WorkBook.Close
Set Excel_WorkBook = Nothing
Excel_Application.Quit
Set Excel_Application = Nothing

Main = DTSTaskExecResult_Success
End Function

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.