• VBE Host Application (VB 6.0)

    Author
    Topic
    #381644

    Is it possible to get info on the host application that a particular VBE instance belongs to? Like which host the VBE Instance belongs to.

    Here is a little bit of background, that may clarify my question.

    I am writing a COM Add-In for the VBE. I have run into an issue if the VBE host application in MS Project. I want to code a workaround for the problems that occurs when the add-in is used in the Project VBE.

    I would just normally just use this code “across the board” for all cases, but this workaround limits, some what, the usability of the Add-In.

    Thanks.

    Viewing 1 reply thread
    Author
    Replies
    • #644298

      Bryan,

      I have not tested this, but it might work.

      From what I ican tell, each office application has 2 BuiltIn references, one concerning VBA-VBE and the Application’s own object library.
      On that basis the following just might work :

      Dim refVBE
      For Each refVBE In Application.VBE.ActiveVBProject.References
      With refVBE
      If .BuiltIn = True And .Name “VBA” Then
      MsgBox “This Add In is hosted by ” & .Name
      End If
      End With
      Next refVBE
      Set refVBE = Nothing

      Andrew C

      • #644299

        Thanks Andrew.

        I’ll give this a shot later on today.

      • #644352

        This worked great. My Add-In now plays well with Project 2000.

        Thanks Andrew

    • #644390

      If you have access to David Boctor’s Microsoft Office 2000 Visual Basic for Applications Fundamentals, check out pp476-478. He recommends this:

      In a regular module, add
      Public HostApp as Object

      In the Connect class module, make this the first line of the procedure IDTExtensibility2_OnConnection
      Set HostApp = Application

      At least for Office apps, you then can check HostApp.Name as needed to do app-specific stuff.

      • #644404

        Unfortunately, with a COM Add-In for the VBE, the Host is the VBE and not the VBE’s host application, if that makes any sense.

        HostApp (Using your variables) would be a VBE object and not a Word object for the VBE in Word.

        That is where my problem lay, but the solution provided by Andrew works.

        I have managed to test it in Project, Excel, Access, Word, PowerPoint and FrontPage.

    Viewing 1 reply thread
    Reply To: VBE Host Application (VB 6.0)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: