Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8704553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:08:07+00:00 2026-06-13T03:08:07+00:00

I am having some problems with a c++ dll i recently got from a

  • 0

I am having some problems with a c++ dll i recently got from a friend.
I am trying to import the dll into an Excel VBA Add-in.
(I am using Excel 2010 32bit and the dll is compiled in Visual Studio 2008)

First of all i tried to import it but it failed with a runtime error 49.
I concluded that it possibly comes from a missing c++ declaration (__stdcal).
(i thought visual studio should do this automatically but okay)

Now i have a new dll with __stdcal in its declaration, but the methods are declared with a underscore ( _ ) at its beginning.

So when i try to declare the Sub, Excel tells me something like “invalid character”
is there a possibility to avoid this without altering the c++ files ?

'void _SaveFile(const char *FileName_);'
Declare Sub _SaveFile Lib "D:/DLL/TableController.dll" (ByRef FileName_ As String)
            ^
            |

Thanks in advance

Here are some additional informations which maybe lead to a solution for my problems.

I got now some c++ code to debug my problem…
I still get the runtime error 49 but the dependency walker gives me now the right names of the methods( which is pretty awesome i think 😉 )

I tried to use the same dll in an C# program.
As i expected it worked perfectly normal.
Here is my C# code
this is the import:

        [DllImport("JLTable.dll",CallingConvention=CallingConvention.StdCall)]
        internal static extern void JLReadFile(string _FileName);

        [DllImport("JLTable.dll", CallingConvention = CallingConvention.StdCall)]
        internal static extern long JLGetRowCount();

annd this happens if i click a Button

        TableRunner.JLReadFile(@"D:\file.tab");
        long rows = TableRunner.JLGetRowCount();
        MessageBox.Show(rows.ToString());

Here is my code in VBA
The declaration:

    Declare Function JLReadFile Lib "D:/JLTable.dll" (ByRef FileName_ As String)
    Declare Function JLGetRowCount Lib "D:/JLTable.dll" () As Long

And the call:

    Sub Read()
        Dim path As String
        path = "D:/file.tab"
        JLReadFile (path)
        Dim count As Long
        count = JLGetRowCount()
    End Sub

And Here is also the c++ code i want to call.
Because of some reason my friend doesn’t want me to show what the code exactly does but it still behaves the same way with this code.

The .h file(the JLTable_API is something like #define JLTable_API __declspec(dllexport))

    #define STDCALL
    extern "C"
    {
    JLTABLE_API void STDCALL  JLReadFile(const char *FileName_);
    JLTABLE_API void STDCALL  JLSaveFile(const char *FileName_);
    }

The .c++ file

    void STDCALL  JLReadFile(const char *FileName_)
    {
    //log something to a file
    }
    long STDCALL  JLGetRowCount()
    {
    //log something to a file
    return 0;
    }

I am very grateful for every hint you can give me

And as always
Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:08:09+00:00Added an answer on June 13, 2026 at 3:08 am

    I finally have a solution.
    i found a blog which showed me what i did wrong.

    http://aandreasen.wordpress.com/2008/05/05/how-to-create-a-dll-for-ms-excel-vba-with-microsoft-visual-c-2008-command-line-tools/

    As described you need the correct method name, to figure out which is the correct one i used the dependency walker.
    This finally led me to this declaration

    VBA:

    Declare Sub JLReadFile Lib "D:/JLTable.dll" (ByRef FileName_ As String) Alias "_JLReadFile@4" (ByRef FileName_ As String)
    

    C++:

    void __declspec (dllexport) _stdcall JLReadFile(const char *FileName_);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some problems calling a C function from a DLL, and was hoping
I’m having some difficulties while trying to consume an unmanaged-code dll from my application
I'm having some problems with concurrency when using DLLImport, I have a Dll that
I am having some problems with the PDF files that I make using the
I'm having some problems trying to figure out how to generate a Google Map
I'm having some problems while using PDO. It all seems correct but I am
I'm having some problems building an hierarchistic array structure - I have almost got
I've been trying to get into C++ programming with Eclipse, but I'm having problems
I'm having some problems with a WH_KEYBOARD_LL hook : The reason why I'm using
I'm trying to implement a plugin system, but I'm having some problems. In the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.