Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community

At 16 JUL 2010 07:31:02AM Kauko Laurinolli wrote:

OI v8.08

Trying to read Excel cell and run to this oddity. What am I doing wrong here?

Compile Subroutine [/color]TEST_EXCEL(Col, Row) 
[/color] 
filename=[/color]"I:\+++ Pricing\Test1.xls" 
[/color]oXl=OleCreateInstance([/color]'excel.Application'[/color]) 
oWkbks =oXl-]WorkBooks 
oSheet =OleGetProperty(oWkbks, [/color]'Open'[/color], filename, [/color]0[/color], [/color]1[/color], [/color]1[/color], [/color]''[/color]) 
oXl-]Visible=[/color]0 
[/color]oCells =OleGetProperty(oSheet, [/color]'Worksheets'[/color],[/color]1[/color]) 
[/color] 
Cell    =OleGetProperty(oCells,[/color]'Cells'[/color], [/color]5[/color], [/color]1[/color])     ;[/color]** This works 
[/color]RetVal_1=Cell-]Text 
[/color] 
Cell    =OleGetProperty(oCells,[/color]'Cells'[/color], Row, Col) ;[/color]** This will not work 
[/color]RetVal_2=Cell-]Text 
[/color] 
Col=[/color]1[/color];    Row=[/color]5 
[/color]Cell    =OleGetProperty(oCells,[/color]'Cells'[/color], Row, Col) ;[/color]** This works??? 
[/color]RetVal_3=Cell-]Text 
[/color] 
close  =OleCallMethod(oSheet, [/color]'Close'[/color],[/color]0[/color]) 
close  =OleCallMethod(oXL, [/color]'Quit'[/color]) 
[/color]debug 
[/color]Return[/color][/color][/size]       
  
               

At 16 JUL 2010 08:01AM Keith Alvey wrote:

Kauko,

It could be a copying error, but before the line that does not work, Row & Col are not set …

Simon


At 16 JUL 2010 08:51AM Kauko Laurinolli wrote:

The whole issue is that Col and Row are the PARAMETERS of the subroutine so the are set.

I want to use it as a function when I find what is wrong with the code.


At 16 JUL 2010 10:57AM Keith Alvey wrote:

Kauro,

I presume you have done so, but a debug just before the Cell=command to confirm that they are set correctly .. ??

Simon


At 16 JUL 2010 11:36AM Kauko Laurinolli wrote:

Cell is the one which fails in the failing alternative RetVal_2.

That the issue. Why does it fail when I pass col & row as PARAMETERS of the subroutine?


At 16 JUL 2010 11:41AM Paul Marraffa wrote:

Try If Unassigned(Col) Then Col=1


At 17 JUL 2010 12:02PM Kauko Laurinolli wrote:

Sorry but you are barking at the wrong tree.

Parameters are assigned so this not an issue.


At 18 JUL 2010 12:08AM Paul Marraffa wrote:

Are you positive the assignment is an integer and not a string?


At 18 JUL 2010 10:37AM Kauko Laurinolli wrote:

Thanks,

Compile Subroutine [/color]TEST_EXCEL(Col, Row) 
[/color] 
Col=Int(Col) 
Row=Int(Row)[/color][/color][/size]         
               

solved the issue.

View this thread on the Works forum...

  • third_party_content/community/commentary/forums_works/f7291390bf86785685257762003f4473.txt
  • Last modified: 2024/01/04 20:57
  • by 127.0.0.1