Pass data of arbitrary type between VBA and dll

Viewed 2270

So I am working on an Excel Project that is going to load a C++ dll using VBA. What I'd like to do is to be able to pass an Excel range with no specific type (data can be numerical or categorical) to the C++ dll (The best way I can describe my Excel range is of the type variant).

So the steps probably involve:

  1. Load the dll in VBA
  2. Send the excel range to dll (The range may contain columns of numbers and/or columns of strings)
  3. manipulate the data from excel in the dll file

I am thinking of using excel variant and C++ variant. But it's not clear for me how to use the C++ variant as I couldn't find any good documentations on it.

Another suggestion I received was to ues COM programming.

My Questions:

  • Could a kind soul possibly provide pointers for me on how to proceed? (e.g. by providing the C++ prototype, and a simple example of how to handle the variant)
  • Does anyone know any good documentation/tutorial on using C++ Variants (and perhaps jointly with VBA)?
  • Is using COMs preferable to using VARIANTS if speed is an issue?
  • Is using the C API an option?

UPDATE:

  • The size of the ranges I need to manipulate can be large (~ 500,000 rows).
  • Speed is a factor, thus, I'd like to avoid unnecessary copying as much as possible.
1 Answers
Related