Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem calling C++ DLL from Excel

Problem calling C++ DLL from Excel

Scheduled Pinned Locked Moved C / C++ / MFC
helpphpc++comtutorial
10 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gvanto
    wrote on last edited by
    #1

    I am trying to access a c++ created DLL from within Excel, with semi-success only: I've followed the following tutorial EXACTLY: http://newtonexcelbach.wordpress.com...ng-excel-to-c/ Now, when I try and use the dll-functions that I've declared in the VB code, the function GetPrice(), which takes no arguments and simply returns a number, works fine. However, as soon as I create a dll-function which takes input arguments, I get a #VALUE error in the cell in Excel ("A value used in formula is of the wrong data type" ). I've downloaded the complete sample from the URL above and get the same error when running it (after recalculating the formulas). I've created a test 'proxy' function (in which the code can be stepped through, which calls the dll function) to ensure that values sent to the dll function are indeed of type double and that seems to be the case ... This guy seems to have had the same problem, however no solution was posted: http://www.ozgrid.com/forum/showthread.php?t=54245[^] Any help / tips would be greatly appreciated! g excell dll newbie

    Find Your Dream Job in Australia, Free! http://www.WebCV.com.au

    G 1 Reply Last reply
    0
    • G gvanto

      I am trying to access a c++ created DLL from within Excel, with semi-success only: I've followed the following tutorial EXACTLY: http://newtonexcelbach.wordpress.com...ng-excel-to-c/ Now, when I try and use the dll-functions that I've declared in the VB code, the function GetPrice(), which takes no arguments and simply returns a number, works fine. However, as soon as I create a dll-function which takes input arguments, I get a #VALUE error in the cell in Excel ("A value used in formula is of the wrong data type" ). I've downloaded the complete sample from the URL above and get the same error when running it (after recalculating the formulas). I've created a test 'proxy' function (in which the code can be stepped through, which calls the dll function) to ensure that values sent to the dll function are indeed of type double and that seems to be the case ... This guy seems to have had the same problem, however no solution was posted: http://www.ozgrid.com/forum/showthread.php?t=54245[^] Any help / tips would be greatly appreciated! g excell dll newbie

      Find Your Dream Job in Australia, Free! http://www.WebCV.com.au

      G Offline
      G Offline
      Garth J Lancaster
      wrote on last edited by
      #2

      I can tell you one thing as a tip ... DON'T CROSS POST IN FORUMS !!!!! Find the best forum, post the message ONCE !!!! 'g'

      G 1 Reply Last reply
      0
      • G Garth J Lancaster

        I can tell you one thing as a tip ... DON'T CROSS POST IN FORUMS !!!!! Find the best forum, post the message ONCE !!!! 'g'

        G Offline
        G Offline
        gvanto
        wrote on last edited by
        #3

        Sorry but I don't know which forum is best for this one ( ? )

        Find Your Dream Job in Australia, Free! http://www.WebCV.com.au

        G 2 Replies Last reply
        0
        • G gvanto

          Sorry but I don't know which forum is best for this one ( ? )

          Find Your Dream Job in Australia, Free! http://www.WebCV.com.au

          G Offline
          G Offline
          Garth J Lancaster
          wrote on last edited by
          #4

          this one c/c++/MFC .. 'g'

          1 Reply Last reply
          0
          • G gvanto

            Sorry but I don't know which forum is best for this one ( ? )

            Find Your Dream Job in Australia, Free! http://www.WebCV.com.au

            G Offline
            G Offline
            Garth J Lancaster
            wrote on last edited by
            #5

            so, did you see the discussion following the article where people were talking about 'deployment' and the VS2008 redistributables, the location of the dll etc ?? - any differences ? 'g'

            G 1 Reply Last reply
            0
            • G Garth J Lancaster

              so, did you see the discussion following the article where people were talking about 'deployment' and the VS2008 redistributables, the location of the dll etc ?? - any differences ? 'g'

              G Offline
              G Offline
              gvanto
              wrote on last edited by
              #6

              No I didn't see that ? This is such a weird problem. Don't get why it would work for everyone else but not for me ...

              Find Your Dream Job in Australia, Free! http://www.WebCV.com.au

              G 1 Reply Last reply
              0
              • G gvanto

                No I didn't see that ? This is such a weird problem. Don't get why it would work for everyone else but not for me ...

                Find Your Dream Job in Australia, Free! http://www.WebCV.com.au

                G Offline
                G Offline
                Garth J Lancaster
                wrote on last edited by
                #7

                gvanto wrote:

                Don't get why it would work for everyone else but not for me ...

                ahh, but it didnt work for everyone - go back the page, read down past the initial steps - others did have issues and (may have) fixed them 'g'

                G 1 Reply Last reply
                0
                • G Garth J Lancaster

                  gvanto wrote:

                  Don't get why it would work for everyone else but not for me ...

                  ahh, but it didnt work for everyone - go back the page, read down past the initial steps - others did have issues and (may have) fixed them 'g'

                  G Offline
                  G Offline
                  gvanto
                  wrote on last edited by
                  #8

                  Hmmm that was a bit schoolboy of me not to spot that error, thanks Garth! I've actually just built the same functionality in a C# dll, works like a bomb! Now I have a little design problem: I'd like the function I call in the dll to KEEP a cell dynamically updated (it fetches a security's price from a local db). Two options: 1) Loop within excel and keep calling the dll function (which queries the db and returns the result) 2) Loop within the dll and *somehow* keep the value of the cell WHICH CALLED IT, up to date. (this is how bloomberg's API functions to keep excel cells dynamically updated, very nifty ! I'm thinking that efficiency-wise, 2) would be better (something tells me that having 200 cells repetitively calling a function will cause Excel to hang ... is my hunch correct?) Best, G

                  Find Your Dream Job in Australia, Free! http://www.WebCV.com.au

                  G G 2 Replies Last reply
                  0
                  • G gvanto

                    Hmmm that was a bit schoolboy of me not to spot that error, thanks Garth! I've actually just built the same functionality in a C# dll, works like a bomb! Now I have a little design problem: I'd like the function I call in the dll to KEEP a cell dynamically updated (it fetches a security's price from a local db). Two options: 1) Loop within excel and keep calling the dll function (which queries the db and returns the result) 2) Loop within the dll and *somehow* keep the value of the cell WHICH CALLED IT, up to date. (this is how bloomberg's API functions to keep excel cells dynamically updated, very nifty ! I'm thinking that efficiency-wise, 2) would be better (something tells me that having 200 cells repetitively calling a function will cause Excel to hang ... is my hunch correct?) Best, G

                    Find Your Dream Job in Australia, Free! http://www.WebCV.com.au

                    G Offline
                    G Offline
                    gvanto
                    wrote on last edited by
                    #9

                    PS: I dont have admin rights on this machine else I'd give the VS2008 redistro stuff a go, sure sounds like it could work ...

                    Find Your Dream Job in Australia, Free! http://www.WebCV.com.au

                    1 Reply Last reply
                    0
                    • G gvanto

                      Hmmm that was a bit schoolboy of me not to spot that error, thanks Garth! I've actually just built the same functionality in a C# dll, works like a bomb! Now I have a little design problem: I'd like the function I call in the dll to KEEP a cell dynamically updated (it fetches a security's price from a local db). Two options: 1) Loop within excel and keep calling the dll function (which queries the db and returns the result) 2) Loop within the dll and *somehow* keep the value of the cell WHICH CALLED IT, up to date. (this is how bloomberg's API functions to keep excel cells dynamically updated, very nifty ! I'm thinking that efficiency-wise, 2) would be better (something tells me that having 200 cells repetitively calling a function will cause Excel to hang ... is my hunch correct?) Best, G

                      Find Your Dream Job in Australia, Free! http://www.WebCV.com.au

                      G Offline
                      G Offline
                      Garth J Lancaster
                      wrote on last edited by
                      #10

                      Im sure there are other people out there who can answer that one better than I can ... 'g'

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups