dbTalk Databases Forums  

DTS Referencing Excel Cell Value Fails

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


Discuss DTS Referencing Excel Cell Value Fails in the microsoft.public.sqlserver.dts forum.



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

Default DTS Referencing Excel Cell Value Fails - 07-10-2006 , 07:22 PM






Hi

I get a 'Object not supported error xl_app.Workbooks.Worksheets" when
I add this line in the program:

"If xl_app.Workbooks.Worksheets("Results").Range("A2:A 2") is Null
then"

The sample code I am running is

Function Main()

'References to Excel
dim xl_app
dim xl_Spreadsheet

SET xl_app = CREATEOBJECT("Excel.Application")

'SET xl_app = GetObject("\\archive\Daily\Report.xls")

SET xl_spreadsheet =
xl_app.Workbooks.Open("\\archive\Daily\Report.xls" )


'Run the macro

If xl_app.Workbooks.Worksheets("Results").Range("A2:A 2") is Null then

xl_app.Run("transform_macro")

End If
xl_spreadsheet.Save

xl_spreadsheet.Close

xl_app.Quit
set xl_app = Nothing

etc....
-------

What is the correct syntax to reference a Cell value and check if it is
Null? I have tried various combinations to no avail. Thanks.


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

Default Re: DTS Referencing Excel Cell Value Fails - 07-11-2006 , 03:23 AM






Hello javathehutt,

Quote:
Hi

I get a 'Object not supported error xl_app.Workbooks.Worksheets" when
I add this line in the program:

"If xl_app.Workbooks.Worksheets("Results").Range("A2:A 2") is Null
then"

The sample code I am running is

Function Main()

'References to Excel
dim xl_app
dim xl_Spreadsheet
SET xl_app = CREATEOBJECT("Excel.Application")

'SET xl_app = GetObject("\\archive\Daily\Report.xls")

SET xl_spreadsheet =
xl_app.Workbooks.Open("\\archive\Daily\Report.xls" )
'Run the macro

If xl_app.Workbooks.Worksheets("Results").Range("A2:A 2") is Null
then

xl_app.Run("transform_macro")

End If
xl_spreadsheet.Save
xl_spreadsheet.Close

xl_app.Quit
set xl_app = Nothing
etc....
-------
What is the correct syntax to reference a Cell value and check if it
is Null? I have tried various combinations to no avail. Thanks.



Function Main()

'References to Excel
dim xl_app
dim xl_Spreadsheet
dim wkb
dim wks
Set xl_app = CreateObject("Excel.Application")
Set xl_spreadsheet = xl_app.Workbooks.Open("\\archive\Daily\Report.xls" )

xl_app.DisplayAlerts = False

'Run the macro
If IsEmpty ( xl_app.Workbooks(1).Worksheets("Results").Range("A 2").value
) then
xl_app.Run("transform_macro")
End If
xl_spreadsheet.Save
xl_spreadsheet.Close

xl_app.DisplayAlerts = True

xl_app.Quit
set xl_app = Nothing
Main = DTSTaskExecResult_Success
End function


Bye




Reply With Quote
  #3  
Old   
javathehutt
 
Posts: n/a

Default Re: DTS Referencing Excel Cell Value Fails - 07-11-2006 , 05:09 PM




Davide wrote:
Fantastic and works like a charm! Thanks much!


Quote:
Hello javathehutt,

Hi

I get a 'Object not supported error xl_app.Workbooks.Worksheets" when
I add this line in the program:

"If xl_app.Workbooks.Worksheets("Results").Range("A2:A 2") is Null
then"

The sample code I am running is

Function Main()

'References to Excel
dim xl_app
dim xl_Spreadsheet
SET xl_app = CREATEOBJECT("Excel.Application")

'SET xl_app = GetObject("\\archive\Daily\Report.xls")

SET xl_spreadsheet =
xl_app.Workbooks.Open("\\archive\Daily\Report.xls" )
'Run the macro

If xl_app.Workbooks.Worksheets("Results").Range("A2:A 2") is Null
then

xl_app.Run("transform_macro")

End If
xl_spreadsheet.Save
xl_spreadsheet.Close

xl_app.Quit
set xl_app = Nothing
etc....
-------
What is the correct syntax to reference a Cell value and check if it
is Null? I have tried various combinations to no avail. Thanks.




Function Main()

'References to Excel
dim xl_app
dim xl_Spreadsheet
dim wkb
dim wks
Set xl_app = CreateObject("Excel.Application")
Set xl_spreadsheet = xl_app.Workbooks.Open("\\archive\Daily\Report.xls" )

xl_app.DisplayAlerts = False

'Run the macro
If IsEmpty ( xl_app.Workbooks(1).Worksheets("Results").Range("A 2").value
) then
xl_app.Run("transform_macro")
End If
xl_spreadsheet.Save
xl_spreadsheet.Close

xl_app.DisplayAlerts = True

xl_app.Quit
set xl_app = Nothing
Main = DTSTaskExecResult_Success
End function


Bye


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.