dbTalk Databases Forums  

refresh excel workbook with active X task

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


Discuss refresh excel workbook with active X task in the microsoft.public.sqlserver.dts forum.



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

Default refresh excel workbook with active X task - 07-26-2006 , 06:15 AM






I have created an active X task to open, refresh, and save an excel workbook
prior to mailing it in a send mail task. When I execute the step, I get a
dialog message that "This action will cancel a pending refresh command.
Continue?" Even if I select OK, the workbook does not update, but the step
completes successfully. Where does the pending refresh come from, and why
does the update fail yet report success? Script below:

'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************

' UpdateExcelWorkbook
Option Explicit

Function Main()

Dim Excel_Application
Dim Excel_WorkBook

Dim sFilename

sFilename = DTSGlobalVariables("gv_ExcelFileLocation").Value

Set Excel_Application = CreateObject("Excel.Application")

' Open the workbook specified
Set Excel_WorkBook = Excel_Application.Workbooks.Open(sFilename)

Excel_WorkBook.RefreshAll
Excel_WorkBook.Save

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

Main = DTSTaskExecResult_Success
End Function

Thanks in advance
Fred

Reply With Quote
  #2  
Old   
Fred
 
Posts: n/a

Default RE: refresh excel workbook with active X task - 07-26-2006 , 09:08 AM






Answered my own question. I had Background Query selected in Data Range
Properties. It was my own save and close commands cancelling the update.
Deselected Background Query and it works fine.
--
Fred


"Fred" wrote:

Quote:
I have created an active X task to open, refresh, and save an excel workbook
prior to mailing it in a send mail task. When I execute the step, I get a
dialog message that "This action will cancel a pending refresh command.
Continue?" Even if I select OK, the workbook does not update, but the step
completes successfully. Where does the pending refresh come from, and why
does the update fail yet report success? Script below:

'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************

' UpdateExcelWorkbook
Option Explicit

Function Main()

Dim Excel_Application
Dim Excel_WorkBook

Dim sFilename

sFilename = DTSGlobalVariables("gv_ExcelFileLocation").Value

Set Excel_Application = CreateObject("Excel.Application")

' Open the workbook specified
Set Excel_WorkBook = Excel_Application.Workbooks.Open(sFilename)

Excel_WorkBook.RefreshAll
Excel_WorkBook.Save

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

Main = DTSTaskExecResult_Success
End Function

Thanks in advance
Fred

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.