Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,

Suppose I Have created a dictionary like:
C#
Dictionary<string,object> dict = new Dictionary<string,object>();
dict.Add("First", "1");
dict.Add("Second", "2");
dict.Add("third", "3");
dict.Add("Forth", "4");

and I am passing this dictinary to VBA.but it is not coming properly there because it its .NET object.
So is there any parsing function by which I can parse the .NET data types to VBA data types.
I am having dictionary and List type of objects in C# that I want to pass.
Please let me know.

Thanks and Regards
Monil Gangar
Posted
Updated 9-Oct-12 10:58am
v3
Comments
Sergey Alexandrovich Kryukov 9-Oct-12 10:23am    
Why?
[no name] 9-Oct-12 16:55pm    
The best question of the day.
+5
Sergey Alexandrovich Kryukov 10-Oct-12 2:00am    
Thank you, Meysam.
I don't know if you noticed that I ask this question quite regularly. I just cannot stand it. :-)
--SA
monil gangar 10-Oct-12 3:02am    
Hii,
I have created a ComVisible .net application dll
from that i am passing a dictionary to VBA but there it is not coming to variant or VBA dictionary.
i think .net dictionary and VBA dictionary are not the same.some sort of parsing is required for the .net dicionary to convert into VBA dictionary. so is there any direct conversion classes present in .net?
-Thanks

 
Share this answer
 
The exact function to convert .net dictionary into Excel dictionary (custom list) doesn't exists, but you can use Dictionary.CopyTo[^] to copy dictionary into an array and then use AddCustomList[^] function to add custom list.

Remarks:

If the list you're trying to add already exists, this method (AddCustomList) does nothing.
 
Share this answer
 
Comments
monil gangar 15-Oct-12 7:14am    
Thank you Maciej Los,
I will try this.
can this solution works with VSTO addin also.?
from VSTO addin i am making call to VBA and in that call i am passing the .net dictionary.
let me try ur solution.
if you know more about how to pass from VSTO addin please let me know.

-Monil

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900