Hi all, I am converting a COM-addin developed with VB6 to a VSTO addin with VB.NET 2008. Again, I am encountering problems with the customization context. See my implementation below. The addin specific menu appears for a millisecond when starting the addin in debug mode, but immediately disappears. What's causing this behaviour? Thanks in advance for your answers. Best regards Bernd =========================================================================== Protected Overrides Sub InitializeUserInterface() Dim FName As String _ = ApplSettings.Files.WordCustomizationContext.Pathname If IO.File.Exists(FName) Then Dim OldCustomizationContext As Object _ = MyOfficeApplication.CustomizationContext With MyOfficeApplication .AddIns.Add(FileName:=FName), Install:=True) MyContextTemplate = .Templates(FName) .CustomizationContext = MyContextTemplate End With ' Adds a menu to the active commandbar. MyBase.InitializeUserInterface() MyContextTemplate.Saved = True ' Restore old customization context to avoid that the addin ' specific context is accidently used by foreign addins. MyOfficeApplication.CustomizationContext = OldCustomizationContext End If End Sub
I forgot to mention: it's a Word addin :-) Bernd Schend schrieb: > Hi all, > > I am converting a COM-addin developed with VB6 to a VSTO addin > with VB.NET 2008. > Again, I am encountering problems with the customization context. > See my implementation below. > > The addin specific menu appears for a millisecond > when starting the addin in debug mode, but immediately disappears. > > What's causing this behaviour? > Thanks in advance for your answers. > > Best regards > Bernd > > =========================================================================== > Protected Overrides Sub InitializeUserInterface() > > Dim FName As String _ > = ApplSettings.Files.WordCustomizationContext.Pathname > If IO.File.Exists(FName) Then > Dim OldCustomizationContext As Object _ > = MyOfficeApplication.CustomizationContext > > With MyOfficeApplication > .AddIns.Add(FileName:=FName), Install:=True) > MyContextTemplate = .Templates(FName) > .CustomizationContext = MyContextTemplate > End With > > ' Adds a menu to the active commandbar. > MyBase.InitializeUserInterface() > > MyContextTemplate.Saved = True > > ' Restore old customization context to avoid that the addin > ' specific context is accidently used by foreign addins. > MyOfficeApplication.CustomizationContext = OldCustomizationContext > End If > > End Sub