Click here to Skip to main content
15,912,205 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Multithreading slower? Pin
NikWing7-May-10 0:50
NikWing7-May-10 0:50 
QuestionMaximum number in an array? Pin
Adam Wike6-May-10 4:51
Adam Wike6-May-10 4:51 
AnswerRe: Maximum number in an array? Pin
Luc Pattyn6-May-10 5:04
sitebuilderLuc Pattyn6-May-10 5:04 
AnswerRe: Maximum number in an array? Pin
dan!sh 6-May-10 5:06
professional dan!sh 6-May-10 5:06 
GeneralRe: Maximum number in an array? Pin
Adam Wike6-May-10 7:36
Adam Wike6-May-10 7:36 
GeneralRe: Maximum number in an array? Pin
Adam Wike7-May-10 4:08
Adam Wike7-May-10 4:08 
QuestionOutlook Addin Pin
Dominick Marciano5-May-10 10:48
professionalDominick Marciano5-May-10 10:48 
QuestionAddIn stopped working Pin
Sonhospa5-May-10 2:38
Sonhospa5-May-10 2:38 
Hi everybody,

I have a funny problem developing an Excel-AddIn with VB Express 2008, based on sample code. The funny thing is that it used to work (at this stage only installing a button), but after working on other projects and coming back it doesn't show the initial message anymore, i.e. the addin doesn't connect. In the other project I had played around with VB's IMessageFilter - so I'm a bit afraid that I keep blocking any Windows messages without knowing?

Maybe someone can have a quick look at the code or has an idea what else might go wrong now? Here's the code:
Option Explicit On
Imports Microsoft.Office.Core
Imports Extensibility

Public Class Connect
    Implements IDTExtensibility2

    Public ext_cm_Startup As ext_ConnectMode
    Public ext_dm_HostShutdown As ext_DisconnectMode
    Public edlcaption As String = ChrW(&H3B1) & ChrW(&H3A9) & "-ED&L"

    Dim oHostApp As Object
    Dim WithEvents MyButton As CommandBarButton

    Private Sub IDTExtensibility2_OnConnection(ByVal Application As Object, ByVal ConnectMode As ext_ConnectMode, _
                                               ByVal AddInInst As Object, ByRef custom As System.Array) _
                                               Implements IDTExtensibility2.OnConnection

        On Error Resume Next
        ' Set a reference to the host application...
        oHostApp = Application

        ' If you aren't in startup, then manually call OnStartupComplete...
        If (ConnectMode <> ext_cm_Startup) Then _
           Call IDTExtensibility2_OnStartupComplete(custom)

    End Sub

    Private Sub IDTExtensibility2_OnStartupComplete(ByRef custom As System.Array) Implements IDTExtensibility2.OnStartupComplete
        Dim oCommandBars As Microsoft.Office.Core.CommandBars
        Dim oStandardBar As Microsoft.Office.Core.CommandBar

        On Error Resume Next
        ' Set up a custom button on the "Standard" commandbar...
        oCommandBars = oHostApp.CommandBars
        If oCommandBars Is Nothing Then
            ' Outlook has the CommandBars collection on the Explorer object
            oCommandBars = oHostApp.ActiveExplorer.CommandBars
        End If

        oStandardBar = oCommandBars.Item("Standard")
        If oStandardBar Is Nothing Then
            ' Access names it's main toolbar Database
            oStandardBar = oCommandBars.Item("Database")
        End If

        ' In case the button was not deleted, use the exiting one...
        MyButton = oStandardBar.Controls.Item(edlcaption)
        If MyButton Is Nothing Then

            MyButton = oStandardBar.Controls.Add(1)
            With MyButton
                .Caption = edlcaption
                .Style = MsoButtonStyle.msoButtonCaption
                .Tag = "EDL"

                .OnAction = "!<MyCOMAddin.Connect>"
                .Visible = True
            End With
        End If

        ' Display a simple message to know which application you started in...
        MsgBox("Started in " & oHostApp.Name & ".")

        oStandardBar = Nothing
        oCommandBars = Nothing
    End Sub

    Private Sub IDTExtensibility2_OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array) _
    Implements IDTExtensibility2.OnDisconnection

        On Error Resume Next
        If RemoveMode <> ext_dm_HostShutdown Then _
           Call IDTExtensibility2_OnBeginShutdown(custom)

        oHostApp = Nothing

    End Sub

    Private Sub IDTExtensibility2_OnBeginShutdown(ByRef custom As System.Array) Implements IDTExtensibility2.OnBeginShutdown
        On Error Resume Next
        ' Notify the user you are shutting down, and delete the button...
        MsgBox(String.Format("Der Button '{0}' wird gelöscht.", MyButton.Caption))
        MyButton.Delete()
        MyButton = Nothing
    End Sub

    Private Sub IDTExtensibility2_OnAddInsUpdate(ByRef custom As System.Array) Implements IDTExtensibility2.OnAddInsUpdate
        'You do nothing if this is called, but you need to
        'add a comment so Visual Basic properly implements the function...
    End Sub

    Private Sub MyButton_Click1(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean) Handles MyButton.Click
        MsgBox("Hier wird eine Aktion vom Add-In ausgeführt!")
    End Sub

    Private Function listFiles(ByVal dir As String) As List(Of String)

        Return Nothing
    End Function
End Class
After compiling, I can successfully register the dll with regasm
regasm MyCOMAddIn.dll /codebase /tlb=MyCOMAddIn.tlb
Gacutil /if MyCOMAddIn.dll
and into the registry
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\Addins\MyComAddin.Connect]
"LoadBehavior"=dword:00000003
"CommandLineSafe"=dword:00000000
"FriendlyName"="MyComAddin Connect Class"
"Description"="MyComAddin Connect Class"
Thank you for your time!
Mick
AnswerRe: AddIn stopped working Pin
tosch5-May-10 3:43
tosch5-May-10 3:43 
GeneralRe: AddIn stopped working Pin
Sonhospa5-May-10 6:01
Sonhospa5-May-10 6:01 
AnswerRe: AddIn stopped working Pin
Johan Hakkesteegt5-May-10 21:23
Johan Hakkesteegt5-May-10 21:23 
GeneralRe: AddIn stopped working Pin
Sonhospa6-May-10 7:30
Sonhospa6-May-10 7:30 
NewsConnecting, but still something wrong Pin
Sonhospa6-May-10 9:49
Sonhospa6-May-10 9:49 
GeneralRe: Connecting, but still something wrong Pin
Johan Hakkesteegt6-May-10 20:39
Johan Hakkesteegt6-May-10 20:39 
GeneralRe: Connecting, but still something wrong Pin
Sonhospa6-May-10 22:21
Sonhospa6-May-10 22:21 
QuestionFilesize Conversion Pin
Dayekh5-May-10 2:29
Dayekh5-May-10 2:29 
AnswerRe: Filesize Conversion Pin
DaveAuld5-May-10 2:57
professionalDaveAuld5-May-10 2:57 
GeneralRe: Filesize Conversion Pin
Luc Pattyn5-May-10 3:14
sitebuilderLuc Pattyn5-May-10 3:14 
GeneralRe: Filesize Conversion Pin
Dayekh5-May-10 3:51
Dayekh5-May-10 3:51 
GeneralRe: Filesize Conversion Pin
DaveAuld5-May-10 4:55
professionalDaveAuld5-May-10 4:55 
GeneralRe: Filesize Conversion Pin
Richard MacCutchan5-May-10 7:31
mveRichard MacCutchan5-May-10 7:31 
GeneralRe: Filesize Conversion Pin
scottgp5-May-10 7:43
professionalscottgp5-May-10 7:43 
GeneralRe: Filesize Conversion Pin
Paul Conrad6-May-10 9:15
professionalPaul Conrad6-May-10 9:15 
GeneralRe: Filesize Conversion Pin
Dayekh5-May-10 3:14
Dayekh5-May-10 3:14 
GeneralRe: Filesize Conversion Pin
Luc Pattyn5-May-10 3:45
sitebuilderLuc Pattyn5-May-10 3:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.