how do I update stock quotes using automation with vb

G

Guest

I'm using VB 6 with Win XP Pro and Office 2002. I have a spreadsheet with msn
stock quotes that updates successfully using the keyboard (alt+u) or the
mouse (click on update quotes).

However, sending the same keys using sendkeys from VB 6 produces the "#Name"
error in Excel, with no prices updated.

Any ideas on how to use sendkeys to accomplish the quote update? Or another
method?

Thanks
 
M

Myrna Larson

What routine is called when you click the button from the worksheet? Why not
call that routine from your VB program?

BTW, MS has a stock quotes add-in that you can download from their web site.
 
G

Guest

I am using the MSN stock quotes addin to update the quotes. I have tried
creating a macro to click the Update button, but the macro doesn't recognize
the click event. Is there a macro setting that prevents some click events
from being recognized?

Thanks
 
B

Bill Martin

John said:
I'm using VB 6 with Win XP Pro and Office 2002. I have a spreadsheet with msn
stock quotes that updates successfully using the keyboard (alt+u) or the
mouse (click on update quotes).

However, sending the same keys using sendkeys from VB 6 produces the "#Name"
error in Excel, with no prices updated.

Any ideas on how to use sendkeys to accomplish the quote update? Or another
method?

Thanks

If you right click on the button and follow your nose through the menus a bit
you can see the name of the macro assigned to that button. Then from your macro
you're writing you can just directly call that macro by name rather than
screwing around with the button.

Bill
 
B

Bill Martin

John said:
I tried this but the MSN commands don't show up in the Commands list.
Thanks

:
------------------------

There are no command lists involved.

Right click on the button, then on "Assign Macro" and you should see the name of
the called macro in the little box at the top of the panel. Cancel out of
there, then create a new macro as follows:

sub ExecuteButton()
Call ButtonNameMacro()
end sub

You should see the button macro executed when you run this new macro.

Bill
 
G

Guest

Bill;
If I right-click on the Update button I get a menu of toolbars, as if
clicking on the View-Toolbars menu.

However, I have found a workaround - if I manually open Excel and leave it
running the VB Sendkeys method is successful. If VB starts Excel, then the
Sendkeys method fails.

Thanks to all for helping.

John F.
 
B

Bill Martin

John said:
Bill;
If I right-click on the Update button I get a menu of toolbars, as if
clicking on the View-Toolbars menu.

However, I have found a workaround - if I manually open Excel and leave it
running the VB Sendkeys method is successful. If VB starts Excel, then the
Sendkeys method fails.

Thanks to all for helping.

John F.

:
-------------------

Ah -- apparently your button in question was placed into the tool bar rather
than onto the spreadsheet itself. That's typically done from within the VBA
code of the application. You'd have to look into the VBA to understand what
they're calling.

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top