| View previous topic :: View next topic |
| Author |
Message |
Mina Guest
|
Posted: Thu Nov 20, 2003 9:09 am Post subject: Retrieve cell value from web page? |
|
|
I'd like to retrieve a value from a web page and use it for calculations. Basically, I'd like to get the current share price of a mutual fund, place that value in the spreadsheet, and use it for calculations.
Is there a way to do this? I've searched a while and don't see much about this. Could this be done with a macro of a sort?
thanks,
Mina |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8980 Location: Lexinton, Kentucky, USA
|
Posted: Thu Nov 20, 2003 9:18 am Post subject: |
|
|
| Copy & paste of a single value worked for me. |
|
| Back to top |
|
 |
Bryan Guest
|
Posted: Thu Nov 20, 2003 9:36 am Post subject: |
|
|
Errr, I'll rephrase that..
I'd like to have the spreadsheet retrieve the value from the web page automatically. With a list of five mutual funds, I'd like the spreadsheet to retrieve the current NAV (share price) of the fund from a web page.
Using [Insert -> External data], I can get a block of text from the web page. How can I filter that text down to just the number value I want?
thanks,
Mina |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Thu Nov 20, 2003 10:03 am Post subject: |
|
|
Download the SDK. There is an example in there that does what you are asking.
It is a Calc spreadsheet called "stock".
On Sheet 2, you list the stock symbols you are interested in.
On Sheet 1, you click a button, and the macro goes out to the web, gets the results for right now for all of the symbols, and adds them to rows of the spreadsheet in Sheet 1. It also updates a graph showing the performance of all of the stocks.
If you open the spreadsheet each day and click the button, then over time, you end up with a graph and a table of the prices of the stock at each time you ran the macro. Even if you run the macro at irregular intervals, the "time" axes of the graph is correct, it is just that the data points are irregularly spaced over time. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Nov 20, 2003 10:14 am Post subject: |
|
|
| Thanks! |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Nov 20, 2003 1:06 pm Post subject: |
|
|
Okay, perhaps this is more complex than I expected. When I load the stock spreadsheet and click on the update button, I get a basic runtime error telling me that com.sun.star.container.noSuchElementException.
Also odd, I can't save that example under a different name or edit it. Is there an installation of the SDK I need to follow? |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Thu Nov 20, 2003 9:47 pm Post subject: |
|
|
When I used the stock spreadsheet, I was using it under OOo 1.0.x. I wonder if it has problems under 1.1?
Or maybe it should be used on 1.1 and you are using 1.0?
Maybe I should send you the version I was using from an earlier version of the SDK? _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
Bryan General User

Joined: 20 Nov 2003 Posts: 5
|
Posted: Fri Nov 21, 2003 7:03 am Post subject: |
|
|
| It might be a proxy problem. I tried it at work and it failed as described above. At home it worked perfectly. There's so much code there, and I'm not familiar with that language at all. With time I'll figure it out, but if anyone has just a simple macro to get the current price of a stock and place it in a cell, I'd really appreciate it. |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
|
| Back to top |
|
 |
|