It took HOURs to figure all this out and the answer!? (see older post) The issue that we are having is that the VSTO would work initated from the ribbon, but the VBA when you added a “reference” to the .tlb file would tell you that it could not create an ActiveX object or other message saying “what!?”. Solution: to run from the command line:
regasm /codebase &amp;amp;amp;lt;pathToMyDll&amp;amp;amp;gt; /tlb:&amp;amp;amp;lt;pathToMyTlb&amp;amp;amp;gt;
But that command too could not “just run”. Here is a guy doing the exact same thing as me, except I found this article last – or at least I stopped looking. It is the key. Making VSTO things and wanting to use them in the “old world” and the new. This confirms all I have learned. Lots of links at the bottom about CLSID’s, regasm etc. COM====ActiveX in case you run into ActiveX – it is 100% the same. I used RegShot to see the registry items to learn what to google next
Microsoft has set up MASSIVE hoops to jump through yet again. You have to sign your project with a strong name and to learn how to do that … follow the links under the section How to Make a Strong Name … or cheat like I did.
- go to your project’s Properties and click on Signing.
- On the bottom section: check “Sign the Assembly”
- in the pulldown – choose <new>
- Make a good file name and end it with “0”
- and assign a password
- Make ANOTHER one and give it the same file name and end it with “1” (same password is handy)
- In the top section – click “Select from file” and choose the name ending with the 0 after entering the password
- Make sure your version control software (I am using git) allows the .pfx files to be stored. This whole excercise is to get a unique ID – not for security so the password I chose was super simple
- Settle down the random GUID generation for your COM Class and Interface (do this to reduce mayhem)
Then, to make the regasm command above easy I added it as a step in the InstallShield wizard – but to do that … it has to be a cscript or wscript file. I made a .vbs script file and ironically had to run it with cscript as I used a library that only cscript would use. Here is the code. Making an exe might have been easier.
&amp;amp;lt;/pre&amp;amp;gt; ' bind a variabe to WScript.Shell Set WshShell = CreateObject("WScript.Shell") ' define the path to the regasm.exe file RegAsmPath = "c:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" ProgramDir = "elbsolutions\xladdinTest1" DllFile = "HplAddinAGSL.dll" TlbFile = "HplAddinAGSL.tlb" ' register the dll TotalCommand = "cmd /c " &amp;amp;amp; RegAsmPath &amp;amp;amp; " ""%ProgramFiles%\" &amp;amp;amp; ProgramDir&amp;amp;nbsp; &amp;amp;amp; "\"&amp;amp;nbsp; &amp;amp;amp; DllFile &amp;amp;amp;&amp;amp;nbsp;&amp;amp;nbsp; """ /codebase /tlb:""%ProgramFiles%\" &amp;amp;amp; ProgramDir&amp;amp;nbsp; &amp;amp;amp; "\"&amp;amp;nbsp; &amp;amp;amp; TlbFile &amp;amp;amp;&amp;amp;nbsp; """ 1&amp;amp;gt;&amp;amp;amp;2&amp;amp;gt;""%ProgramFiles%\" &amp;amp;amp; ProgramDir&amp;amp;nbsp; &amp;amp;amp; "\registerResults.txt""" WshShell.run TotalCommand, 0, True Set objStdOut = WScript.StdOut Wscript.StdOut.WriteLine TotalCommand Set objFS = CreateObject("Scripting.FileSystemObject") strFile = "%ProgramFiles%\" &amp;amp;amp; ProgramDir&amp;amp;nbsp; &amp;amp;amp; "\registerResults.txt" strFile = WshShell.ExpandEnvironmentStrings(strFile ) Wscript.StdOut.WriteLine strFile Set objFile = objFS.GetFile(strFile) Set ts = objFile.OpenAsTextStream(1,-2) Do Until ts.AtEndOfStream strLine = ts.ReadLine ' do something with strLine Wscript.StdOut.WriteLine strLine Loop ts.Close &amp;amp;lt;pre&amp;amp;gt;
How to Make a Strong Name – the list of hoops
- Strong-Named Assemblies
Other Links for learning about Registry Keys and COM (or ActiveX)
- create and register tab with regasm
- register .tlb
- Talk about CLSID entries , and another article
- Registering a Class at Install
- COM Registry Keys
- COM Registry items from VS