+ Reply to Thread
Results 1 to 11 of 11

Run time error 1004-get stock quotes

  1. #1
    Registered User
    Join Date
    04-20-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    29

    Run time error 1004-get stock quotes

    Hi all,

    I have a simple function below to put in different forumlas in different cells to get stock quotes. When I run this I get runtime error 1004 application-defined or object-defined error. The first formula goes through but vba chokes on the next formula: ActiveCell.Offset(I - 1, 4).Formula = username
    What am I missing?! thx
    ==============================================================================


    Please Login or Register  to view this content.
    Last edited by LATrojan; 04-26-2009 at 11:58 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    re: Run time error 1004-get stock quotes

    Trojan, be sure to go back to your original post, EDIT, GO ADVANCED, highlight all the code and click on the # icon. [code] and [ /code] tags on all code is a forum rule...


    ...Also, what's your code doing? My system indicates it is trying to launch "edemo.exe". What's that?
    Last edited by JBeaucaire; 04-26-2009 at 11:37 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    04-20-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    29

    re: Run time error 1004-get stock quotes

    Quote Originally Posted by JBeaucaire View Post
    Trojan, be sure to go back to your original post, EDIT, GO ADVANCED, highlight all the code and click on the # icon. [code] and [ /code] tags on all code is a forum rule...


    ...Also, what's your code doing? My system indicates it is trying to launch "edemo.exe". What's that?
    Hey -
    It's using the InteractiveBroker DDE for Excel to download stock quotes. I'm concatenating the strings needed to request the stock data and placing them in cells. As I mentioned it the first formula works fine. It's the second that's giving me problems.

    Thanks Beaucaire!

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    re: Run time error 1004-get stock quotes

    Since I can't run that code because of the edemo.exe, just have to fiddle. Maybe one of these:
    Please Login or Register  to view this content.
    Sorry, I really am just skipping stones on this one.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    re: Run time error 1004-get stock quotes

    It depends on where the active cell is. If it's in row 1, there is no cell above it.

    What is the code supposed to do?

    JB is referring to your prior thread, in which you have not responded to the several suggestions. Please do so.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    04-20-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    29

    re: Run time error 1004-get stock quotes

    Quote Originally Posted by shg View Post
    It depends on where the active cell is. If it's in row 1, there is no cell above it.

    What is the code supposed to do?

    JB is referring to your prior thread, in which you have not responded to the several suggestions. Please do so.
    The way I want to run it is to select a cell that has the ticker symbol of the first stock and run the macro from there. The code is supposed to update a stock price through the Interactive Brokers DDEs.

    About the previous thread, sorry I forgot I had posted it to the general forum. I couldn't find it

    Thanks!

  7. #7
    Registered User
    Join Date
    04-20-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    29

    re: Run time error 1004-get stock quotes

    Quote Originally Posted by JBeaucaire View Post
    Since I can't run that code because of the edemo.exe, just have to fiddle. Maybe one of these:
    Please Login or Register  to view this content.
    Sorry, I really am just skipping stones on this one.
    Hi again. All of those give me the same error. If you just click No when that edemo thing pops up the code goes through. I'm just looking to get that formula in the proper cell. Basically I want the right cell to read "=edemo|tik!'id" (even without the actual data feed).

    It's something to do with the bar "|" and ' symbols. Because if I remove them it works. Do I need to use any special symbols like a backslash in C/C++?

    Thanks!

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    re: Run time error 1004-get stock quotes

    I just did a quick google, on the examples I found none used the ' encasing the string after the tik!, is this definitely required ?

    On an aside do not use Integer as a Data Type for a Row variable given the Integer boundaries (32767) are exceeded by the number of rows available in XL, although (highly) unlikely to cause an issue it can generate overflow issues if you have mass data...
    further, in VBA the Integer type is converted to Long "under the hood" so it's actually thought to be slower than just using Long in the first place (ie Integer -> Long -> Integer slower than Long -> Long) - ie there are no advantages memory wise using Integer in XL, the only advantage is if you want to sanity check your variables (ie deliberately generate an overflow error for unexpectedly large variables)

  9. #9
    Registered User
    Join Date
    04-20-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    29

    re: Run time error 1004-get stock quotes

    Quote Originally Posted by DonkeyOte View Post
    I just did a quick google, on the examples I found none used the ' encasing the string after the tik!, is this definitely required ?
    Hi DonkeyOte - yeah the ' is required according to the documentation from interactive brokers. The strange thing is that it works on the first line and doesn't on the second statement.

    Please Login or Register  to view this content.

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    re: Run time error 1004-get stock quotes

    doesn't that make sense though ? ie the username has no closing '

    I'm not pretending I know what it does, nor can I test, but this

    yabba!'xyz'

    makes sense if the ' is used to denote a variable or somesuch whereas

    yabba!'xyz

    doesn't as there's no closing ' which is what's happening with your username statement (I think) ... in your other line (that works I believe?) you have a closing '

  11. #11
    Registered User
    Join Date
    04-20-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    29

    re: Run time error 1004-get stock quotes

    Quote Originally Posted by DonkeyOte View Post
    doesn't that make sense though ? ie the username has no closing '

    I'm not pretending I know what it does, nor can I test, but this

    yabba!'xyz'

    makes sense if the ' is used to denote a variable or somesuch whereas

    yabba!'xyz

    doesn't as there's no closing ' which is what's happening with your username statement (I think) ... in your other line (that works I believe?) you have a closing '
    That's exactly what it was!! Thanks DonkeyOte!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1