Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / VS Tools for Office / April 2006

Tip: Looking for answers? Try searching our database.

Strange habit with Shared Addin in Word

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
VictorH - 13 Apr 2006 09:21 GMT
I've created a shared addin for Word 2003 in VS 2005 with has a strange habit.
The shared addin creates a commanbar. Everything is working fine, except
that the buttons won't fire if you add new documents in Word. Only in the
available empty document or the last the buttons work, so:

Start Word, only one empty document1 is open, buttons work fine.
Add document by choosing file new -> Document2, buttons don't work in
document2, but in document1.
Close document1, buttons do work in document2.

Who can explain this and more wanted: solve this.

The code for reconstruction: build a addin for Word, keep everthing default
and create this code in Connect.vb

   Private wrdApp As Word.Application (instead of applicationObject as
Object)
   Private mBar As CommandBar
   Private mBarPopup As CommandBarPopup
   Private WithEvents mbarbtnAbout As CommandBarButton

   Public Sub OnDisconnection(ByVal RemoveMode As
Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnDisconnection
       mBar.Delete()
   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
       wrdApp = CType(application, Word.Application)

       mBar = wrdApp.CommandBars.Add("TEST", , , True)

       mBarPopup =
CType(mBar.Controls.Add(Type:=MsoControlType.msoControlPopup, Before:=1,
Temporary:=True), CommandBarPopup)
       mBarPopup.Caption = "Test"

       mbarbtnAbout =
CType(mBarPopup.Controls.Add(MsoControlType.msoControlButton, , , , True),
CommandBarButton)
       mbarbtnAbout.OnAction = "!<MyAddin1.Connect>"
       mbarbtnAbout.Caption = "Click"

       mBar.Visible = True
   End Sub

   Private Sub mbarbtnAbout_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)
Handles mbarbtnAbout.Click
       MsgBox("Clicked")
   End Sub
VictorH - 13 Apr 2006 09:42 GMT
I think I found it myself,
If you add a tag to the buttons, everything seems to work fine..... strange.

> I've created a shared addin for Word 2003 in VS 2005 with has a strange habit.
> The shared addin creates a commanbar. Everything is working fine, except
[quoted text clipped - 49 lines]
>         MsgBox("Clicked")
>     End Sub

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.