Results 1 to 6 of 6
  1. #1
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBE Host Application (VB 6.0)

    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.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: VBE Host Application (VB 6.0)

    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

  3. #3
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBE Host Application (VB 6.0)

    Thanks Andrew.

    I'll give this a shot later on today.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  4. #4
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBE Host Application (VB 6.0)

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

    Thanks Andrew
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: VBE Host Application (VB 6.0)

    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.

  6. #6
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBE Host Application (VB 6.0)

    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.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •