473,320 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

pb: event word addin button.click "File" Menu

hello

I have to create a small addin which works on Powerpoint, Word, Outlook, and Excel on Office 2000, XP, and 2003.
This addin consists in adding 2 new Buttons in the "File" Menu of office. This is properly done, but the events which should be triggered with the button.click method are not triggered in Word.
I don't understand because it properly works in the 3 others host applications.
If someone has an issue, I would be most grateful.
Thanks

here is the code of my connect.vb file:

Imports Microsoft.Office.Core
' importe les objets nénécessaires Ã* la construction des menus ou autres outils
' au sein de microsoft office

Imports Extensibility
' importe l'interface IDTExtensibility2, et les objets nécessaires Ã*
' la "connection" de l'addin Ã* l'application hôte

Imports System.Runtime.InteropServices

#Region " Lisez Moi pour avoir des infos sur l'installation de l'addin sur d'autres postes. "
' Dans la fenetre Solution Explorer de Visual Studio .NET 2003, il faut:
' * click droit sur <nomDuProjet> ; et choisir "build" .
' * click droit sur <nomDuProjet>Setup ; et choisir "build" .
' * Sur l'autre poste :
' ** copier le répertoire du projet en cours.
' ** executer (dans ce répertoire) /MyCOMAddinSetup/debug/setup .
' ** ouvrir une des applications hôte.
#End Region

' classe connect: classe qui lance l'execution de l'addin a chaque lancement
' de l'application hôte. Cette classe implémente l'interface IDTExtensibility2

<GuidAttribute("8EFC12FE-8F9C-4802-88B0-56F297E844E0"), ProgIdAttribute("MyCOMAddin.Connect")> _
Public Class Connect

Implements IDTExtensibility2

Dim applicationObject As Object
Dim addInInstance As Object
Dim WithEvents workitSave As CommandBarButton
Dim WithEvents workitSaveAs As CommandBarButton


Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown
On Error Resume Next
' Notify the user you are shutting down, and delete the button.
MsgBox("Our custom Add-in is unloading.")

workitSave = applicationObject.CommandBars.FindControl(Tag:="wo rkit save")
workitSave.Delete()
applicationObject.NormalTemplate.Save()
workitSave = Nothing

workitSaveAs = applicationObject.CommandBars.FindControl(Tag:="wo rkit save as")
workitSaveAs.Delete()
applicationObject.NormalTemplate.Save()
workitSaveAs = Nothing

End Sub

Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnAddInsUpdate
'
End Sub

Public Sub OnStartupComplete(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnStartupComplete

Dim oCommandBars As CommandBars


On Error Resume Next

oCommandBars = applicationObject.CommandBars
If oCommandBars Is Nothing Then
' Outlook has the CommandBars collection on the Explorer object.
oCommandBars = applicationObject.ActiveExplorer.CommandBars
End If
workitSave = oCommandBars("File").Controls.Item("workit save")
If workitSave Is Nothing Then
workitSave = oCommandBars("File").Controls.Add(Type:=MsoControl Type.msoControlButton, Id:=1)
workitSave.Caption = "workit save"
workitSave.TooltipText = "workit save"
workitSave.Tag = "workit save"
workitSave.Style = MsoButtonStyle.msoButtonCaption
workitSave.OnAction = "!<MyCOMAddin.Connect>"
End If

workitSaveAs = oCommandBars("File").Controls.Item("workit save as")
If workitSaveAs Is Nothing Then
workitSaveAs = oCommandBars("File").Controls.Add(Type:=MsoControl Type.msoControlButton, Id:=1)
workitSaveAs.Caption = "workit save as"
workitSaveAs.TooltipText = "workit save as"
workitSaveAs.Tag = "workit save as"
workitSaveAs.Style = MsoButtonStyle.msoButtonCaption
workitSaveAs.OnAction = "!<MyCOMAddin.Connect>"
End If

' Display a simple message to show which application you started in.
MsgBox("Started in " & applicationObject.Name & ".")
oCommandBars = Nothing
End Sub

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

On Error Resume Next
If RemoveMode <> Extensibility.ext_DisconnectMode.ext_dm_HostShutdo wn Then _
Call OnBeginShutdown(custom)

applicationObject = Nothing
End Sub

Public Sub OnConnection(ByVal application As Object, ByVal connectMode As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnConnection
MsgBox("On Connection In MyAddin")
applicationObject = application
addInInstance = addInInst
' If you aren't in startup, manually call OnStartupComplete.
If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup) Then _
Call OnStartupComplete(custom)

End Sub
Private Sub workitSave_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean) Handles workitSave.Click
MsgBox("vous voulez sauver ds workit")
End Sub

Private Sub workitSaveAs_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean) Handles workitSaveAs.Click
MsgBox("vous voulez sauver ds workit mais sous un autre nom")
End Sub

End Class
__________________________________________________ _____
it's a very simple code that make the same mistake on every configuration of PC I tried.
Thanks

Nov 20 '05 #1
0 2378

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Peter van der Goes | last post by:
I'm reposting for a person who asked this in the academic group, as I (obviously) don't have a clue and am curious to know if it can be done: "I´m trying to get the tooltip text of the files that...
0
by: MartinABeck | last post by:
I am trying to put a word document into a c# program the same as described at this link http://support.microsoft.com/?id=304662 . I have been able to get this to work but I am in need of the file...
0
by: maitrepoy | last post by:
Hello I have to create a small addin which works on Powerpoint, Word, Outlook, and Excel on Office 2000, XP, and 2003. This addin consists in adding 2 new Buttons in the "File" Menu of office....
2
by: maitrepoy | last post by:
hello I have to create a small addin which works on Powerpoint, Word, Outlook, and Excel on Office 2000, XP, and 2003. This addin consists in adding 2 new Buttons in the "File" Menu of office....
1
by: Sarvjeet Saini | last post by:
Hi all, I need to incorporate new menu option in File menu of every MS word . Are Addins helpful in this case . I need to Create a setup which will add this functionality to existing as...
2
by: Goran Djuranovic | last post by:
Hi all, I was getting this error when trying to move files on a FileSystemWatcher notification (with in a Windows Service). To fix this, I implemented a FileWaiter class to wait for the file to be...
9
by: Prakash Singh Bhakuni | last post by:
am replacing the default "Browse..." button for input type=file. This works fine except that the form will only submit after the SUBMIT button is clicked twice. Any ideas on why this is happening...
1
by: bhushan097 | last post by:
hi , if you control user to right clik on page then why not is is possible to disable "save as" in file menu ? plz suggest solution Bhushan.
0
by: yazhen | last post by:
Can somebody tell me how to read/ display the content of microsoft word file in ASP.net web form, and able to genearate smart menu on fly when mouse over the content. The content of file may include...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.