Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 4th, 2006, 08:58 AM
Registered User
 
Join Date: Mar 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using Msnstockquote from excel VBA

I am able to load a cell in an Excel spreadsheet with something like

=MSNStockQuote("msft","Last Price","US")

However, I would like to load a variable in a VBA module with something like:

curPrice = MSNStockQuote("msft","Last Price","US")

butI get “Variable Not Defined” even though curPrice is defined.

I also tried unsuccessfully with:
curPrice = MSNStockQuote.Functions.MSNStockQuote("msft", "Last Price", "US")

How do I call the MSNStockQuote function from within a VBA module. ?

And is it possible to use this call to return more than one parameter at a time,. Say I wanted Price and time of day as well. Can I do this with a single Function call?

Thanks,

Gary


 
Old July 5th, 2006, 12:57 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

When I enter what you have here verbatim, I get the familiar #NAME?

How do you have this MSNStockQuote? Is it a library that you have added to your Excel project? Or . . . ?
 
Old July 5th, 2006, 05:47 PM
Registered User
 
Join Date: Mar 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, MSNStockQuote is a Microsoft PlugIn for Excel 2003. You can download it at
http://www.microsoft.com/downloads/d...DisplayLang=en

Gary

 
Old October 25th, 2006, 04:23 PM
Registered User
 
Join Date: Oct 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

this works for me (after installing and then adding the reference in Tools | references of course)....

Sub Test()
    Dim x As New MSNStockQuote.Functions
    y = x.MSNStockQuote("URBN", "Last", "US")
End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
Code works in Excel VBA but not Access VBA fossx Access VBA 2 May 21st, 2007 08:00 AM
Converting excel data to Access using excel VBA ShaileshShinde VB Databases Basics 1 April 26th, 2006 07:57 AM
VBA Excel jayanp Access VBA 3 December 16th, 2004 03:18 AM
Excel VBA to SQL & back to VBA edesousa Excel VBA 1 June 1st, 2004 02:39 AM
Excel with VBA myquestq Excel VBA 1 November 7th, 2003 05:45 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.