+ Reply to Thread
Results 1 to 4 of 4

Calling DLL function from Excel VBA doesn't return value

  1. #1
    Registered User
    Join Date
    04-08-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    3

    Unhappy Calling DLL function from Excel VBA doesn't return value

    I decided to convert my VBA XLAM add-in to VB6 COM DLL and did so. Most functions work well except those that involve passing excel objects.

    As a simple example consider the following.

    Please Login or Register  to view this content.
    the above is a simple function defined in VB6 COM DLL named say MyDLL in a class named say myDClass. The project is compiled into a DLL and a reference to it is added from within Excel VBA project. The below is the VBA wrapper to the above DLL function defined in Excel VBA.

    Please Login or Register  to view this content.
    When I call the above function and debug it from within VB6 and VBA both, I can see that the range object is passed to the DLL and the DLL function is able to operate on it and return the row count successfully (from within VB6 IDE). But once the function call returns back to VBA, the return value is empty and ReturnRowCount above returns zero even though dllReturnRowCount succeeded. I can get other functions that do not involve passing Excel objects to return values of types Date, String, Boolean etc. successfully.

    So, the question is how do I get the above to work the way it should ? What am I doing wrong ?

    Thanks for any help.
    Last edited by AcesHigh; 04-09-2013 at 01:16 PM.

  2. #2
    Registered User
    Join Date
    04-08-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Calling DLL function from Excel VBA doesn't return value

    Bump ?

    46 views, no answers !

    Can someone at least suggest a forum or IRC where I can post my question and hope to get some answer ?
    Last edited by AcesHigh; 04-09-2013 at 10:37 AM.

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Calling DLL function from Excel VBA doesn't return value

    How are you calling the function?

    That information seems to be missing from your post.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    04-08-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Calling DLL function from Excel VBA doesn't return value

    How are you calling the function?

    That information seems to be missing from your post.
    The second code block in my post (the VBA wrapper function) is what I have in Excel VBA as a wrapper function for the DLL function and that is how it is being called. I hope that explains unless I misunderstand your question.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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