Getting a Reference to the Current Visual Basic IDE

In the beginning, we named the class associated with this project CodeGeneratorClass. We need to put some code into this class. Add the following into the CodeGeneratorClass:

Option Explicit Implements IDTExtensibility

IDTExtensibility will give us the events that we will need to get a reference to the Visual Basic IDE. Remember, when you use an interface you will need to use all of the methods in the interface. If you look in the object drop down of the Visual Basic IDE (the left drop down box) you will see that the IDTExtensibility has been added.

We will use OnConnection event to get a copy of the Visual Basic IDE. Go to the object drop down of the Visual Basic IDE and select IDTExtensibility. OnConnection will include a parameter called VBInst, which is a copy of the Visual Basic IDE. We will pass this to the frmMain VBInstance property:

Private Sub IDTExtensibility_OnConnection(ByVal _ VBInst As Object, ByVal ConnectMode As _ VBIDE.vbext_ConnectMode, ByVal AddInInst As _ VBIDE.AddIn, custom() As Variant) Set frmMain.VBInstance = VBInst frmMain.Show End Sub

We will now just fill in the rest of the events of the interface with comments:

Private Sub IDTExtensibility_OnDisconnection(ByVal _ RemoveMode As VBIDE.vbext_DisconnectMode, _ custom() As Variant) ' Comment to prevent procedure from being ' deleted on compilation.

End Sub

Private Sub IDTExtensibility_OnStartupComplete _

(custom() As Variant) ' Comment to prevent procedure from being ' deleted on compilation. End Sub

Private Sub IDTExtensibility_OnAddInsUpdate _

(custom() As Variant) ' Comment to prevent procedure from being ' deleted on compilation. End Sub

Was this article helpful?

0 0
365 Days Of Motivation

365 Days Of Motivation

Stop Wasting Time And Learn How To Stay Motivated. Finally! Discover How To Stop Your Mind From Wandering, And Upgrade Your Motivation. You Can Hack Your Motivation Levels, Allowing You To Take Your Life To The Next Level.

Get My Free Ebook


Post a comment