How to get current instance of Visual Basic
How to set variable named "vbi", which is a variable to reference the current instance of Visual Basic.
Variable vbi used in samples : Manipulating Projects with Add-Ins (MSDN Library Visual studio 6).The following code fragments demonstrate how to reference the VBProject object and VBProjects collection, as well as other extensibility objects:
' Create new project.
Private Sub cmdCreateNew_Click()
Dim p As VBProject
Set p = vbi.VBProjects.Add _
(cmbProjKind.ItemData(cmbProjKind.ListIndex))
If txtProjName.Text <> "" Then
p.Name = txtProjName.Text
End If
End Sub
' Activate component.
Private Sub cmdActivate_Click()
Dim sc As String
Dim sp As String
Dim c As VBComponent
sp = cmbProj.Text
sc = cmbComp.Text
If sp <> "" And sc <> "" Then
Set c = _
vbi.VBProjects.Item(sp).VBComponents.Item(sc)
c.Activate
End If
End Sub
' Create new component of the type indicated in the
' cmbCompKind combo.
Private Sub cmdCreateNewVBComponent_Click()
Dim p As VBProject
Dim c As VBComponent
Dim sp As String
sp = cmbProj.Text
If sp <> "" Then
Set p = vbi.VBProjects.Item(sp)
Set c = p.VBComponents.Add _
(cmbCompKind.ItemData(cmbCompKind.ListIndex))
End If
End Sub
Thanks,
Dusan Grujic
e-mail:
ozisabac@ptt.yu