Canonical: How to call .NET methods from Excel VBA
问题 I have found a way to call .NET 2 code directly from a VBA macro: Dim clr As mscoree.CorRuntimeHost Set clr = New mscoree.CorRuntimeHost clr.Start Dim domain As mscorlib.AppDomain clr.GetDefaultDomain domain Dim myInstanceOfDotNetClass As Object Set myInstanceOfDotNetClass = domain.CreateInstanceFrom(\"SomeDotNetAssembly.dll\", \"Namespace.Typename\").Unwrap Call myInstanceOfDotNetClass.ExecuteSomeDotNetMethod (To make this code work I had to add references to mscoree.tlb and mscorlib.tlb to