Results 1 to 4 of 4

Thread: [RESOLVED] Problem with AddinInstance_OnConnection event in a VB6 Add-In

  1. #1

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,855

    Resolved [RESOLVED] Problem with AddinInstance_OnConnection event in a VB6 Add-In

    Ok, I recently (earlier today) posted a small Add-In in the CodeBank. However, someone else is getting a "Compile error: Procedure declaration does not match description of event or procedure having the same name". The compile error line is on the event declaration of AddinInstance_OnConnection.

    I've searched, and everywhere I see the AddinInstance_OnConnection, it's declared just as I declared it. Here that is:

    Code:
    
    Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
    
    

    In fact, there's just the DSR module to the Add-In, and there's not that much code. Here's the whole thing:

    Code:
    
    Option Explicit
    '
    Dim VBInstance               As VBIDE.VBE
    Dim mcbMenuCommandBar        As Office.CommandBarControl
    Dim WithEvents MenuHandler   As CommandBarEvents                         ' Command bar event handler.
    '
    ' VBInstance.CommandBars("Standard").Controls.Add(Type, Id, Parameter, Before, Temporary)
    '   Type       Optional    Variant The type of control to be added to the specified command bar. Can be one of the following MsoControl constants: msoControlButton, msoControlEdit, msoControlDropdown, msoControlComboBox, or msoControlPopup.
    '   Id         Optional    (built in ICON) Variant An integer that specifies a built-in control. If the value of this argument is 1, or if this argument is omitted, a blank custom control of the specified type will be added to the command bar.
    '   Parameter  Optional    Variant For built-in controls, this argument is used by the container application to run the command. For custom controls, you can use this argument to send information to Visual Basic procedures, or you can use it to store information about the control (similar to a second Tag property value).
    '   Before     Optional    Variant A number that indicates the position of the new control on the command bar. The new control will be inserted before the control at this position. If this argument is omitted, the control is added at the end of the specified command bar.
    '   Temporary  Optional    Variant True to make the new control temporary. Controls are automatically deleted when the container application is closed. The default value is False.
    '
    
    Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
        Set VBInstance = Application
        '
        ' Add the button, and sink events.
        Set mcbMenuCommandBar = VBInstance.CommandBars("Standard").Controls.Add(1, , , VBInstance.CommandBars("Standard").Controls.Count - 1)
        mcbMenuCommandBar.FaceId = 5
        mcbMenuCommandBar.ToolTipText = "Copy Module Name"
        Set MenuHandler = VBInstance.Events.CommandBarEvents(mcbMenuCommandBar)
    End Sub
    
    Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
        mcbMenuCommandBar.Delete    ' Delete the button.
    End Sub
    
    Private Sub MenuHandler_Click(ByVal CommandBarControl As Object, Handled As Boolean, CancelDefault As Boolean)
        If VBInstance.VBProjects.Count > 1 Then
            MsgBox "This doesn't currently work for VB groups.  Please open individual projects and try again.", vbCritical, App.Title
        Else
            Clipboard.Clear
            Clipboard.SetText VBInstance.SelectedVBComponent.Name
        End If
        '
        Handled = True          ' We've done what we want, no further action needed.
        CancelDefault = True    ' Don't do whatever the Office button typically does.
    End Sub
    
    

    And here are two other places that are discussing the same error, here and here.

    But sadly, neither of those places presents a solution.

    Does anyone know what's going on here?

    Thanks In Advance,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  2. #2
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,121

    Re: Problem with AddinInstance_OnConnection event in a VB6 Add-In

    Just remove CopyModuleName.DCA from the zip file. It's the ActiveX Designer cache file with some kind of type info as collected by the compiler from your machine's registry probably.

    And btw, don't ship any OCA files with your user-controls too :-))

    cheers,
    </wqw>

  3. #3
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

    Re: Problem with AddinInstance_OnConnection event in a VB6 Add-In

    Removed CopyModuleName.DCA from the folder and it compiled instantly!!!

  4. #4

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,855

    Re: Problem with AddinInstance_OnConnection event in a VB6 Add-In

    wqweto,

    Thank you very much. I'll remove it now.

    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

Posting Permissions

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



Click Here to Expand Forum to Full Width