Classic VBA and .NET

I have a C# form that I would like to display whenever Word is opened.  Right now, I think I'm going to make a C# class, exposed as a COM object like this:

class Activator {
   MyForm f;
   public void Init(Document document) {
      f = new MyForm(document);
      f.Show();
   }
   public void Destroy() {
      f.Close();
   }
}

2 questions:
1) How do I expose the Activator class as a COM object that I can access from VBA?  Most importantly, what registration would I have to do on the user's computer to be able to use this class?
2) If I use the following VBA code:
Set a = CreateObject("Activator")
a.Init ThisDocument
Will my form remain on the screen until I call a.Close or will the Activator object go out of scope?
LVL 4
thedude112286Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zahabyCommented:
about question 1

you have 2 ways to expose :
a- use GUID
[Guid("B6F829AA-D1D0-4f14-9B3E-D8D4FA033819")]

public class ConfigurationBuilder : IConfigurationBuilder

{...}

b- use the ClassInterfaceType

[ClassInterface(ClassInterfaceType.None)]

public class ConfigurationBuilder : IConfigurationBuilder

{...}

USING VBA
VBA client would use this object as ordinary COM
'declare events and NetForm object
Dim WithEvents NetEvent As NetForm
Dim dotNetForm As New NETobject.NetForm

Set NetEvent = dotNetForm
etc

====================

2- will get out of scope
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zahabyCommented:
0
thedude112286Author Commented:
How would I keep my COM class from going out of scope and closing my form?
0
zahabyCommented:
thanx very much
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.