Presenter:Steve Hansen
Learn how to manage custom task panes within a Word add-in. Since custom task panes are associated with windows and individual Word documents appear in different windows, as a Word add-in developer, you need to manage multiple task panes if you’d like the task panes to behave in a unified manner. This video shows you how to do it.
The following text is a software generated transcript of the video. Click on a minute link to jump to a location within the video
Minute 0
I m a name is Steve Hanson with office over that time the studios have minutes task panes in a word and in some of the challenges of doing them in for word is that slow but different than 60 word is also similar is in full path and the difference is that in word when you put the document documents are open up in new windows so unlike Excel when you look at a document in a so earned additional document the document is opened in the same window so no as I resize the window and Excel and switch between my documents the document appears in the same window so working with that task themes in him and in a Microsoft Word task panes can attach to a
Minute 1
And Windows unlike Excel when you re using task panes in an Excel and you can create one task pane is always visible regardless of the document that s active some of this video is to show you how tremendous task panes in the word and so that your task panes appear as the same task pane regardless of which document the users using it to demonstrate them to create a simple user control is the tax simple text box on here who are the things that also like to demonstrate a
Minute 2
To sync task pane so remember your and have actually multiple instances of the task pane you do need to sync them all some of the ways you can go about doing that is just provide properties in control so that it s real easy to update your control similar to have a simple string property here called a simple text in an immediate and stepped routines of his update the value of the text box pending on how the property changes of the soul couple of the things I need to do here is to provide a way to add a task pane need to provide a way to add task panes to
Minute 3
I ll be active when those rural open documents need to provide a way to remove the single task pane need to provide a way to remove all task panes Just adding a task pane this can require a document parameter and then they ll just do the code that you write if you were doing this in Excel or something have a custom testing mode will use custom task panes that add a new instance of my user control provided vital in this instance on going to assign it to the active window of the document that was passed in and then set the visible property to true so that all go to the ad
Minute 4
Task panes so this particular one I call it a want to add a task pane to all of the active windows rolled the document windows sofa is at least a little more documents of the families who freaks document in application documents and memos simply call the ad task pane procedure within the loop so this will do is to remove a task pane remove a single single task pane or the task pane associated with a document this was a little trickier than you might
Minute 5
You might think at first you need a few variables here one is a window variable CTP window a CTP or custom task pane variable than rather than enumerate through the custom testings collection you need to do a for loop using the index and you will start at the top and then work your way backwards the reason you can use the enumeration here is because when you remove a task name you choose the enumeration and invalidates a solicitous and repeated his statement repeated here a few times of using a phone next loop using an index to retrieve the custom task pane that you are
Minute 6
And the relevance of this loop is in reference to be a single custom task in a minute convert the window the custom testing window to one window than to make sure that as a example task pane and that via window associated with a custom task pane is equal to the window the active window associated with the document if all that is true in the remove the custom task and the next thing that I need to do is provide a removal task panes procedure in for this one I m going to use the same pattern as that of the season and
Minute 7
Acts to work my way through all of the custom task panes in the custom task pane s collection in the mood to see if the title role of the custom task pane equals the title that I ve set out in the immediate at testing collection sums as using the title example task pane and further testing a fine with that title and let go in and remove it another thing I need to do is check for orphaned custom test things
Minute 8
So orphaned custom test things can happen in a few ways one of the primary what ways might be a few for user closes a testing on individual document for example so unless you places for causes from one of the event handlers in Ghana more reputable that but all you remove orphans procedure does is loop through all the task panes and see if the window associated with the task with the current custom testing is nothing so there s no window associated with the task pane and then go and remove it excellent that provide a way to toggle the task panes so if you provide your users the ability to turn
Minute 9
Your test things out of your way to show and hide the ball flew to listen to take or use a class when very well called the showroom testings in a known to do is check that very moment if their code of the testes are currently showing in the call removal task panes if they re not currently showing a minute call and testings and that I m going to toggle the value of that variable that each and provide a way to sync a task panes so if you change to the value of the control in one task pane and you want to make that change visible and all the other task panes
Minute 10
You need to provide a procedure that will handle that synchronization will do here is I tuned in this one using enumeration and bought through my custom task pane s collection to see if the title role of the current task pane is my example task pane title this is going to set the value of my temporary variable equal to the contrast from the custom task pane in the numbers for the change the example example text property threatens a forgotten here is a need to pass in the user control as a parameter to this procedure so that an
Minute 11
A little back into my user control and would call this procedure from within the text changed event handler for the thing to do is to work all the event handler is called the correct procedures so so I ll go ahead and all ads has been stormed the act of documents and shut down all removable also need to look at the document before close in you to remove task panes
Minute 12
At one deed I can change that is what I m going to call my remove orphans document than and new document server for the document closes you remove the task pane associated with the document in the document changes as good place to check for orphans the document open about him and attesting to a woman into document I ll go ahead and add a task pane to the new document knucklehead in at a
Minute 13
Driven to the project in the most relentlessly tried a single button and then add the amount is called the problem task panes procedure filters might talk about and to just a button simply on the action to unload one and update the label smell my building and wellness when asked
Minute 14
To happen is that of the long term task panes I love using it about men and women I should see my task panes being synchronized between all the task panes with all the open documents it s human testing in all open documents as well so good and applicable documents and no minimized windows you can see going to be task panes and no second turn them on and off from my ribbon button and as I enter change value of the control I see it in the other testing that concludes us to do and how to manage task panes in a word and thanks for watching everything
Click here to go to original video page
Tuesday, June 3, 2008
Video: How Do I: Manage Task Panes in Word Add-ins?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment