dbTalk Databases Forums  

ActiveX task working with Excel

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


Discuss ActiveX task working with Excel in the microsoft.public.sqlserver.dts forum.



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

Default ActiveX task working with Excel - 10-05-2005 , 02:18 PM






I have an activeX task that I am using and trying to write out to an Excel
file. I run the task, and if I go into the file right away, it will say that
another process still has it open and I can see that my values have been
written to the file. If I close it and reopen it, the file is empty. I
haven't had to do anything like this for a few years so I'm sure I'm missing
something. Any help is appreciated. My script is below:

Function Main()

Dim objExcel, strPathExcel
Set objExcel = CreateObject("Excel.Application")
strPathExcel = DTSGlobalVariables("File").Value
objExcel.Workbooks.open strPathExcel
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)

objSheet.Cells(1,1).Value = "Consumer Aprv_Amt Total"
objSheet.Cells(1,2).Value = "Business AsgnLn_Amt Total"
objSheet.Cells(1,3).Value = "Business AEEAprv_Amt"
objSheet.Cells(1,4).Value = "Distinct BusEmpSeq"
objSheet.Cells(1,5).Value = "Distinct PAS EntrdSys_Dt"
objSheet.Cells(1,6).Value = "Distinct DNS EntrdSys_Dt"
objSheet.Cells(1,7).Value = "Distinct SOL EntrdSys_Dt"



Main = DTSTaskExecResult_Success
End Function




Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: ActiveX task working with Excel - 10-05-2005 , 02:55 PM






Do you not have to save and close the spreadsheet?

Something like

Excel_WorkBook.Save

' Clean Up Excel Objects
Excel_WorkBook.Close
Set Excel_WorkBook = Nothing
Excel_Application.Quit
Set Excel_Application = Nothing




"Andy" <Andy (AT) discussions (DOT) microsoft.com> wrote


Quote:
I have an activeX task that I am using and trying to write out to an
Excel
file. I run the task, and if I go into the file right away, it will say
that
another process still has it open and I can see that my values have been
written to the file. If I close it and reopen it, the file is empty. I
haven't had to do anything like this for a few years so I'm sure I'm
missing
something. Any help is appreciated. My script is below:

Function Main()

Dim objExcel, strPathExcel
Set objExcel = CreateObject("Excel.Application")
strPathExcel = DTSGlobalVariables("File").Value
objExcel.Workbooks.open strPathExcel
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)

objSheet.Cells(1,1).Value = "Consumer Aprv_Amt Total"
objSheet.Cells(1,2).Value = "Business AsgnLn_Amt Total"
objSheet.Cells(1,3).Value = "Business AEEAprv_Amt"
objSheet.Cells(1,4).Value = "Distinct BusEmpSeq"
objSheet.Cells(1,5).Value = "Distinct PAS EntrdSys_Dt"
objSheet.Cells(1,6).Value = "Distinct DNS EntrdSys_Dt"
objSheet.Cells(1,7).Value = "Distinct SOL EntrdSys_Dt"



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.