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

button Click event triggerd twice in com add-in word 2003

I created com add-in for word2003, excel2003 and powerpoint2003,
basically, i added 4 button in toobar and on_click, i apply some
bussiness logic. all works in excel2003 and powerpoint 2003, but in
word2003, the button event has been tiggered twice. After i click, it
run the code inside the button click, then run again. so annoying.

code attached below,Any help and suggestion will be great appriciated
Wendy
Imports Office = Microsoft.Office.Core
Imports Extensibility
Imports System.Runtime.InteropServices

Imports Word = Microsoft.Office.Interop.Word

<GuidAttribute("BF60D3CC-02A1-42f5-B17D-1965D13E7BB7"),
ProgIdAttribute("Office_AddIn.ConnectWord")> _
Public Class ConnectWord
Implements Extensibility.IDTExtensibility2

Dim applicationObject As Object
Dim addInInstance As Object

Private Shared WithEvents FEWordApplication As Word.Application

Dim FEToolbar As Microsoft.Office.Core.CommandBar = Nothing

Private WithEvents BtnEventsOptions As Office.CommandBarButton
Private WithEvents BtnEventsClassify As Office.CommandBarButton
Public Sub OnBeginShutdown(ByRef custom As System.Array)
Implements Extensibility.IDTExtensibility2.OnBeginShutdown
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
End Sub

Public Sub OnDisconnection(ByVal RemoveMode As
Extensibility.ext_DisconnectMode, ByRef custom As System.Array)
Implements Extensibility.IDTExtensibility2.OnDisconnection
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
applicationObject = application
addInInstance = addInInst
Setup(application)

If Not application Is Nothing Then
FEToolbar = AddToolBar(application, "RM Office 2003
Activator.")
End If

BtnEventsClassify = MakeANewButton(FEToolbar, "RM Classify",
0, _
AddressOf BtnEventsClassify_Click)
BtnEventsClassify.Tag = "word_classity"

BtnEventsOptions = MakeANewButton(FEToolbar, "RM Options", 0, _
AddressOf BtnEventsOptions_Click)
BtnEventsOptions.Tag = "word_options"

End Sub

Public Shared Function Setup(ByVal oApp As Word.Application) As
Boolean
FEWordApplication = oApp
End Function
Private Sub p_ctlBtnEventsOptions_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As
Boolean) Handles p_ctlBtnEventsOptions.Click
MsgBox("I am in Option_click")

End Sub

Private Sub p_ctlBtnEventsClassify_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As
Boolean) Handles p_ctlBtnEventsClassify.Click

MsgBox("I am in Classity_click")

End Sub

End Class

Public Function MakeANewButton(ByVal commandBar As _
Microsoft.Office.Core.CommandBar, ByVal caption As String, _
ByVal faceID As Integer, ByVal clickHandler As _
Microsoft.Office.Core._CommandBarButtonEvents_Clic kEventHandler) _
As Microsoft.Office.Core.CommandBarButton
Try
Dim newButton As Microsoft.Office.Core.CommandBarButton
newButton = CType(commandBar.Controls.Add( _
Microsoft.Office.Core.MsoControlType.msoControlBut ton),
_
Microsoft.Office.Core.CommandBarButton)
newButton.Caption = caption
newButton.FaceId = faceID
newButton.DescriptionText = "My button"
newButton.Style =
Office.MsoButtonStyle.msoButtonCaption
AddHandler newButton.Click, clickHandler
Return newButton
Catch ex As System.Exception
Return Nothing
End Try
End Function
Jul 21 '05 #1
0 1353

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

Similar topics

3
by: Jason Kyle Baginski | last post by:
Here's a little test app to demonstrate a problem I'm having. It creates four buttons, each one with the different FlatStyle types available. Three of them behave exactly the same way(and the...
2
by: Oney | last post by:
I want to open a popup window when user click the web server button control When user click the button, only OnClik="OpenWindow(12)" is sent but no event happend no popup opened.After...
2
by: gce | last post by:
Allthough button2 created with the designer works 100%. The button I created (inside the table) with dim button1 as new button doesn't give me a click event. Please help. Public Class WebForm8 ...
11
by: Sarah | last post by:
I have code that I want to run so that if the result is true, it changes the current button's ".DialogResult" property to "DialogResult.OK". Problem is, when I run this code on the ".Click" event...
11
by: Bernie Yaeger | last post by:
If the user clicks the processit button, the click event code runs. What happens if he/she clicks it again before it's done processing? Does the system remember and process twice? Does it ignore...
0
by: Brian Mitchell | last post by:
Hello, I have a toolbar which I am populating the buttons at runtime. All of my buttons have drop down menus associated with them as well as a click event on the button itself. If a user clicks...
3
by: Neil Wallace | last post by:
Hi, This is an odd one. I've been struggling to get "double click" to work well for my controls. The same event handler works perfectly for buttons, but not for labels. Can anyone tell me...
6
by: pedestrian via DotNetMonster.com | last post by:
I have a simple VB ASP.NET 2.0 page with a Button and a Label. The Label text is "0". For each click of the button (btnAdd), it should increment the Label text by 1. The code: Protected Sub...
0
by: csgraham74 | last post by:
Hi, I have a weird problem that is happening on my ASP.Net (1.1) web application. I have built a page that has a button control. Basiaclly this performs a search using a datarow. The problem is...
1
by: daonho | last post by:
I tried to use javascript to trigger up the button click function when user press enter key from the textbox. This function work fine with a single button click such has login page. However, if the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.