I have successfully been able to run my own .Net code by following the steps posted here Execute .NET 3.0 code from Office 2003
Is there a way to use the standard .N
You should be able to use ComVisible
.NET classes in this way. However the GenerateKey
and GenerateIV
methods don't have a return value. Try:
Sub Macro1()
Dim aesImplementation As New RijndaelManaged
aesImplementation.GenerateKey
Key = aesImplementation.Key
aesImplementation.GenerateIV
IV = aesImplementation.IV
End Sub
or better, not least because when debugging you can see whether an error occurs during construction or when you call the method:
Sub Macro1()
Dim aesImplementation As RijndaelManaged
Set aesImplementation = New RijndaelManaged
aesImplementation.GenerateKey
Key = aesImplementation.Key
aesImplementation.GenerateIV
IV = aesImplementation.IV
End Sub
Not yet possible. VBA (VB for Applications) is not VB, but rather a separate deal mimicking all the basic syntax as older versions of VB. It's almost like using a very stripped down version of regular, older VB. In fact, VBScript is the closest match to VBA. Perhaps someday, Microsoft will build in methods to work directly with the GAC, but until then (and that day will likely mean the death of COM I'm sure), you're stuck using COM CreateObject()
method, adding a reference to a COM registered library to your Office project, or directly referencing a VBA/COM compatible DLL or TLB file in your Office project.
There are quite a few COM-enabled libraries in the default GAC, but for the majority, you are stuck creating a Com Callable Wrapper first in VB.Net or C#.
Conversely, pretty much all MS Office apps are COM callable, so you can work with installed Office apps through VB.Net projects all you want.