Read Excel with Object Rexx

  • Follow


Is there an example somewhere of how to use Object Rexx to read an Excel
file?


0
Reply jerry 11/4/2004 12:19:30 AM

Jerry,
I've got a couple of examples at http://pragmaticlee.safedataisp.net

If that is not enough, give me some examples of what you want to do
and I'll try to provide the code.

Lee Peedin
VP RexxLA

On Thu, 04 Nov 2004 00:19:30 GMT, "jerry chapman"
<jerryc314@sbcglobal.net> wrote:

>Is there an example somewhere of how to use Object Rexx to read an Excel
>file?
>

0
Reply Lee 11/4/2004 3:46:33 AM


Jerry,
My email was out of date on my last post - this post should have the
correct email address if you desire to contact me directly.

BTW:
On the referenced web-page look for the file Excel_demo.zip
This zip file includes a PowerPoint Presentation that will detail how
to automate Microsoft Excel via Object Rexx 2.1.1. Please review this
presentation BEFORE running the demonstration application. The demo
application may need to be modified in regards to file paths - adjust
as necessary to your own system. 

Lee 


On Thu, 04 Nov 2004 03:46:33 GMT, Lee Peedin
<leepeedin_AT@_mindspring.DOTcom@> wrote:

>Jerry,
>I've got a couple of examples at http://pragmaticlee.safedataisp.net
>
>If that is not enough, give me some examples of what you want to do
>and I'll try to provide the code.
>
>Lee Peedin
>VP RexxLA
>
>On Thu, 04 Nov 2004 00:19:30 GMT, "jerry chapman"
><jerryc314@sbcglobal.net> wrote:
>
>>Is there an example somewhere of how to use Object Rexx to read an Excel
>>file?
>>

0
Reply Lee 11/4/2004 3:57:17 AM

I built a small example based on Excel_demo.zip.

My_Excel=.OleObject~New('Excel.Application')
OpenIt=My_Excel~Workbooks~Open('C:\My_File.xls')
Row=1
Col='A'
Cell_Value=My_Excel~Cells(Row,Col)~Value
say 'value' Cell_Value
exit

When I ran it I got an error on then following line:

Cell_Value=My_Excel~Cells(Row,Col)~Value

An unknown OLE error occured (HRESULT=C0000005)

Am I missing something?


0
Reply jerry 11/4/2004 2:03:28 PM

"jerry chapman" <jerryc314@sbcglobal.net> schrieb> Am I missing something?
>
Have you tried my mm.rex ?
works like a charm on my Windows XP

Walter 


0
Reply Walter 11/4/2004 2:48:21 PM

Jerry,
Try this code (watch for line wraps!!)

This expects there to be a my_file.xls in the root drive c:\

/* test_excel.rex */

My_Excel=.OleObject~New('Excel.Application')

-- if you want to watch what is happening remove the comment indicator
(of course it will be fast)
-- my_excel~visible = .true

OpenIt=My_Excel~Workbooks~Open('C:\My_File.xls')

/*
Jerry, at this point you are confusing "setting a value" & "retrieving
a value"

Row=1
Col='A'
Cell_Value=My_Excel~Cells(Row,Col)~Value
say 'value' Cell_Value

Try this
*/

-- this will retrieve the value of the cell
row = 1
col = 'A'                   
existing_value = My_Excel~Cells(row,col)~value
say 'The value of cell' row||col '=' existing_value

-- this will set the value of the cell
row = 1
col = 'A'                   
newvalue = existing_value * 2
say 'The value of cell' row||col 'will be changed to =' newvalue
My_Excel~Cells(row,col)~value = newvalue

say 'The new value of cell' row||col '=' My_Excel~Cells(row,col)~value

-- Make this true if you want to confirm overwriting the existing file
my_excel~displayalerts = .false


-- Save the workbook with the new value
my_excel~activeworkbook~save

--Close the workbook IF you want to use your object (my_excel) to open
another one
my_excel~activeworkbook~close

-- Be sure you quit the application - if you don't you leave Excel
running
-- Check you processes now and kill any Excel you may have left open
(or reboot)
my_excel~quit
exit



On Thu, 04 Nov 2004 14:03:28 GMT, "jerry chapman"
<jerryc314@sbcglobal.net> wrote:

>I built a small example based on Excel_demo.zip.
>
>My_Excel=.OleObject~New('Excel.Application')
>OpenIt=My_Excel~Workbooks~Open('C:\My_File.xls')
>Row=1
>Col='A'
>Cell_Value=My_Excel~Cells(Row,Col)~Value
>say 'value' Cell_Value
>exit
>
>When I ran it I got an error on then following line:
>
>Cell_Value=My_Excel~Cells(Row,Col)~Value
>
>An unknown OLE error occured (HRESULT=C0000005)
>
>Am I missing something?
>

0
Reply Lee 11/4/2004 4:09:26 PM

By modifing the example supplied by Walter u. Christel Pachl I was able to
everything I need to do.

My new task is to create an Excel file.

Where can I find examples of tasks such as: setting column width, setting
row height and setting border type and width?
"Lee Peedin" <lpeedinREMOVE@UPPERCASEnc.rr.com> wrote in message
news:gukko0le843eik5ugph1cs30564dn4k2p2@4ax.com...
> Jerry,
> Try this code (watch for line wraps!!)
>
> This expects there to be a my_file.xls in the root drive c:\
>
> /* test_excel.rex */
>
> My_Excel=.OleObject~New('Excel.Application')
>
> -- if you want to watch what is happening remove the comment indicator
> (of course it will be fast)
> -- my_excel~visible = .true
>
> OpenIt=My_Excel~Workbooks~Open('C:\My_File.xls')
>
> /*
> Jerry, at this point you are confusing "setting a value" & "retrieving
> a value"
>
> Row=1
> Col='A'
> Cell_Value=My_Excel~Cells(Row,Col)~Value
> say 'value' Cell_Value
>
> Try this
> */
>
> -- this will retrieve the value of the cell
> row = 1
> col = 'A'
> existing_value = My_Excel~Cells(row,col)~value
> say 'The value of cell' row||col '=' existing_value
>
> -- this will set the value of the cell
> row = 1
> col = 'A'
> newvalue = existing_value * 2
> say 'The value of cell' row||col 'will be changed to =' newvalue
> My_Excel~Cells(row,col)~value = newvalue
>
> say 'The new value of cell' row||col '=' My_Excel~Cells(row,col)~value
>
> -- Make this true if you want to confirm overwriting the existing file
> my_excel~displayalerts = .false
>
>
> -- Save the workbook with the new value
> my_excel~activeworkbook~save
>
> --Close the workbook IF you want to use your object (my_excel) to open
> another one
> my_excel~activeworkbook~close
>
> -- Be sure you quit the application - if you don't you leave Excel
> running
> -- Check you processes now and kill any Excel you may have left open
> (or reboot)
> my_excel~quit
> exit
>
>
>
> On Thu, 04 Nov 2004 14:03:28 GMT, "jerry chapman"
> <jerryc314@sbcglobal.net> wrote:
>
> >I built a small example based on Excel_demo.zip.
> >
> >My_Excel=.OleObject~New('Excel.Application')
> >OpenIt=My_Excel~Workbooks~Open('C:\My_File.xls')
> >Row=1
> >Col='A'
> >Cell_Value=My_Excel~Cells(Row,Col)~Value
> >say 'value' Cell_Value
> >exit
> >
> >When I ran it I got an error on then following line:
> >
> >Cell_Value=My_Excel~Cells(Row,Col)~Value
> >
> >An unknown OLE error occured (HRESULT=C0000005)
> >
> >Am I missing something?
> >
>


0
Reply jerry 11/5/2004 2:20:41 AM

6 Replies
321 Views

(page loaded in 0.004 seconds)

Similiar Articles:













7/30/2012 3:06:37 PM


Reply: