473,322 Members | 1,287 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,322 software developers and data experts.

pb: event Word click addin menu "File" button

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 1893

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

Similar topics

2
by: Laermans_k | last post by:
Hi, Does anyone have a solution to use the <input type="file" id="filechooser"> and the <input type="submit" id="submitbutton"> in 1 button click? I've already tried to create a javascript...
0
by: beau | last post by:
Please help me ! Anybody can help me with a code to embed an ms word file into an access table ? I have ms word templates with bookmarks in my hard disk. So far I can open the template...
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...
3
by: Daniel | last post by:
Hi, I have opened the word file from database and display in web browser. When i close the browser, i wan to update the changes into the database. and i dont know how to achieve it. I oni know...
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....
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...
5
by: ssq | last post by:
Hi, Can anyone help me write a code on the Button to Open a MS Word File. Thanks
0
by: Ang | last post by:
Hi, I want to open a word file on background instead of showing the process on client's screen. And then do mailmerge, after that allow user to saveas. (user simply click the button and IE will...
1
by: cyrak | last post by:
Hi when the user click a button I have to make a word file and put a piece of data in one page, put a second piece of data on a second page and give the user the word file is there any simple...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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)...
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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.