Jonathan Frederic
Posts: 14
Joined: 2009-05-27
|
Hi!
I'll try to keep this short and simple. :D
- I created an ADX Project using the wizard.
- I modified the code in the addin class created by the wizard to add a custom ribbon to Word (see below).
- I successfully registered the add-in (Build->Register ADX Project).
- I ran the plugin with Word 2007 on Windows XP and nothing happened. I verified that the code WAS being called by placing a breakpoint in the constructor and stepping through with it.
Imports AddinExpress.MSO
Imports System.Runtime.InteropServices
Imports System.ComponentModel
'Add-in Express Add-in Module
<GuidAttribute("48FDE685-6F98-4404-8164-4F816AA50D6D"), ProgIdAttribute("MyAddin2.AddinModule")> _
Public Class AddinModule
Inherits AddinExpress.MSO.ADXAddinModule
#Region " Component Designer generated code. "
'Required by designer
Private components As System.ComponentModel.IContainer
'Required by designer - do not modify
'the following method
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
'
'AddinModule
'
Me.AddinName = "MyAddin2"
Me.SupportedApps = CType(( _
AddinExpress.MSO.ADXOfficeHostApp.ohaWord _
), AddinExpress.MSO.ADXOfficeHostApp)
End Sub
#End Region
#Region " Add-in Express automatic code "
'Required by Add-in Express - do not modify
'the methods within this region
Public Overrides Function GetContainer() As System.ComponentModel.IContainer
If components Is Nothing Then
components = New System.ComponentModel.Container
End If
GetContainer = components
End Function
<ComRegisterFunctionAttribute()> _
Public Shared Sub AddinRegister(ByVal t As Type)
AddinExpress.MSO.ADXAddinModule.ADXRegister(t)
End Sub
<ComUnregisterFunctionAttribute()> _
Public Shared Sub AddinUnregister(ByVal t As Type)
AddinExpress.MSO.ADXAddinModule.ADXUnregister(t)
End Sub
Public Overrides Sub UninstallControls()
MyBase.UninstallControls()
End Sub
#End Region
Friend mTabPage As ADXRibbonTab
Friend mGroup As ADXRibbonGroup
Friend mEditBox As ADXRibbonEditBox
Public Sub New()
MyBase.New()
'This call is required by the Component Designer
InitializeComponent()
'Please add any initialization code to the AddinInitialize event handler
Dim ControlContainer As System.ComponentModel.IContainer = Me.GetContainer
mTabPage = New ADXRibbonTab(ControlContainer)
mGroup = New ADXRibbonGroup(ControlContainer)
mEditBox = New ADXRibbonEditBox(ControlContainer)
'Make sure controls are displayed in Word.
mTabPage.Ribbons = ADXRibbons.msrWordDocument
mGroup.Ribbons = ADXRibbons.msrWordDocument
mEditBox.Ribbons = ADXRibbons.msrWordDocument
'Add the controls to each other.
mTabPage.Controls.Add(mGroup)
mGroup.Controls.Add(mEditBox)
'Adjust controls.
mTabPage.Caption = "My Tab Page"
mGroup.Caption = "My Group"
mEditBox.Caption = "Caption"
mEditBox.Text = "Text"
'Setup information about the addin.
Me.AddinName = "Custom Addin"
Me.SupportedApps = ADXOfficeHostApp.ohaWord
End Sub
End Class
BTW: I already realize that I am setting AddinName and SupportedApps twice. I figure it doesn't matter at the moment and it makes the code a bit easier to read. |
|
Andrei Smolin
Add-in Express team
Posts: 18817
Joined: 2006-05-11
|
Hi Jonathan,
You forgot to set the ID properties. I've done the same via Add-in Express designer and here's what I get:
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Me.AdxRibbonTab1 = New AddinExpress.MSO.ADXRibbonTab(Me.components)
Me.AdxRibbonGroup1 = New AddinExpress.MSO.ADXRibbonGroup(Me.components)
Me.AdxRibbonButton1 = New AddinExpress.MSO.ADXRibbonButton(Me.components)
'
'AdxRibbonTab1
'
Me.AdxRibbonTab1.Caption = "AdxRibbonTab1"
Me.AdxRibbonTab1.Controls.Add(Me.AdxRibbonGroup1)
Me.AdxRibbonTab1.Id = "adxRibbonTab_ac64c3316bbf4a2580d53ec052cc7b33"
Me.AdxRibbonTab1.Ribbons = AddinExpress.MSO.ADXRibbons.msrWordDocument
'
'AdxRibbonGroup1
'
Me.AdxRibbonGroup1.Caption = "AdxRibbonGroup1"
Me.AdxRibbonGroup1.Controls.Add(Me.AdxRibbonButton1)
Me.AdxRibbonGroup1.Id = "adxRibbonGroup_8ddee55d125144409a6d7091008636d7"
Me.AdxRibbonGroup1.ImageTransparentColor = System.Drawing.Color.Transparent
Me.AdxRibbonGroup1.Ribbons = AddinExpress.MSO.ADXRibbons.msrWordDocument
'
'AdxRibbonButton1
'
Me.AdxRibbonButton1.Caption = "AdxRibbonButton1"
Me.AdxRibbonButton1.Id = "adxRibbonButton_54f1f047e873451dac068942ec2f9614"
Me.AdxRibbonButton1.ImageTransparentColor = System.Drawing.Color.Transparent
Me.AdxRibbonButton1.Ribbons = AddinExpress.MSO.ADXRibbons.msrWordDocument
'
'AddinModule
'
Me.AddinName = "MyAddin142"
Me.SupportedApps = AddinExpress.MSO.ADXOfficeHostApp.ohaWord
End Sub
Andrei Smolin
Add-in Express Team Leader |
|
Jonathan Frederic
Posts: 14
Joined: 2009-05-27
|
Hi Andrei,
That fixed it.
I thought the ID property was automatically assigned if I did not set it. Does the ID have to be in that format to work? Control Name, Underscore, Long Hexadecimal String? Or can I set my control IDs to something off the wall like "ThisIsRibbonA"?
Thanks,
Jon |
|
Andrei Smolin
Add-in Express team
Posts: 18817
Joined: 2006-05-11
|
Hi Jonathan,
A Ribbon ID is a string, so you can use any values, of course.
Andrei Smolin
Add-in Express Team Leader |
|
Jonathan Frederic
Posts: 14
Joined: 2009-05-27
|
Ok, I wasn't sure it if was parsed by Office or something strange like that. |
|