Good morning,
I have a few questions about the ActionsPane, but I think they won't be that difficult. But let me first explain my project:
I need an Add-In for Word 2003, so when starting Word, a custom button should apear. This is already done. Now when click on the button my Actionspane solution should be shown. So I made another project with a Word Template. Now I have 2 projects and one calls the other. Maybe not the best solution but works for now. But now the problems began...
And its also time for the questions:
1. So I have a Word Template (.dot) with an Actionspane, but now I ned to add another Template. But this one is just a texttemplate. So when adding this one, only the text should displayd on the document. But with Me.Application.Documents.Add(textTemplate) a new Window withe the template shows up. So this is BIG problem for me.
But when just drag the .dot file into the open Word window, only the text apears. So I it
must be possible somhow.
2. The second question is simpler. How can i change the size (width, height) of the
Actionspane Me.ActionsPane.Controls.Add(myPane) is done, but now the Actionspane
should be the same size like the added Control, but it just won't! Is it possible and how
Ok its enough ! Thaks for your help !

Some questions about ActionsPane
Milly
Hi Thomas,
From my understanding of your solution, you probably don't need to have two templates. You can write code to add a custom button to a toolbar in the same template that you use to create an actions pane. For information on adding buttons to toolbars, see http://msdn2.microsoft.com/en-us/library/scff9c7c(en-US,VS.80).aspx. You can write code to hide and show the actions pane, according to which button is clicked. For more information, see http://msdn2.microsoft.com/en-us/library/7we49he1(en-US,VS.80).aspx.
Regarding your second question, you cannot resize the ActionsPane object itself (using ActionsPane.Width does not resize the action pane). This is because the ActionsPane object is hosted within the Task Pane. You can, however, resize the Task Pane to fit your control. The following code example shows this by adding a wide control to the actions pane when you double-click a document and resizing the task pane to whatever size the control is (in this case a user control called wideControl). When you right-click the document, the wideControl is removed and a smaller user control named narrowControl is added, and the task pane is resized to the width of narrowControl. Note that I added 15 to the size to account for margins. You can modify this code to work with button click events instead of Document_BeforeDoubleClick and Document_BeforeRightClick.
Dim wideControl As New UserControl1
Dim narrowControl As New UserControl2
Dim wideWidth As Integer = wideControl.Width + 15
Dim narrowWidth As Integer = narrowControl.Width + 15
Private Sub ThisDocument_BeforeDoubleClick(ByVal sender As Object, _
ByVal e As Microsoft.Office.Tools.Word.ClickEventArgs) Handles _
Me.BeforeDoubleClick
Me.ActionsPane.Controls.Remove(narrowControl)
Me.ActionsPane.Controls.Add(wideControl)
Me.CommandBars("Task Pane").Width = wideWidth
End Sub
Private Sub ThisDocument_BeforeRightClick(ByVal sender As Object, _
ByVal e As Microsoft.Office.Tools.Word.ClickEventArgs) Handles _
Me.BeforeRightClick
Me.ActionsPane.Controls.Remove(wideControl)
Me.ActionsPane.Controls.Add(narrowControl)
Me.CommandBars("Task Pane").Width = narrowWidth
End Sub
I hope this helps!
Kathleen
http://blogs.msdn.com/vsto2/
mansb2002
I have a similar scenario and have written a helper application to manage the base templates and add a Solution to a document, this uses the ServerDocument classes and as such allows the templates to be focused with one global solution that is intelligent to render the different functionality. Am happy to discuss this further if you feel this would be relevant as is quite in depth but allows in a limited way to control and add solutions in a base set of templates. There are provisions needed to be thought about for Code Access Security to trust the template location and the assemblies of your VSTO Solution.
Regards
jkishi
I got all my answers, thank you !
This was the last peace I needed to complete my big puzzle. Now I have all my answers. It's not a big project, so im happy with this solution. I wanted to make it like this from the start, but just dindn't know how...I guess Documents.Add() was realy wrong!
Now I can make some boring coding and finish my project. Maybe I will have some problems when the deploying begins, but well see...
Rob P
Thank you for the answer !
The thing with the Taskpane makes things a lil bit clearer. And it works.The first answer is also great, again new inormation. But still theres this lilttle problem I have.
So I have my Word Document. It has this Actionspane und a lot of UserControls. So far so good. Then I have something about 20-30 Templates (Letter, Fax, etc.). I don't kno them all, because I dont make them. So we have my Doc with the Actionspane und 20 Templates. Now whem my Word Document is open (with the Actionspane) it should be possible to load one of these 20-30 Templates into that Document, without opening a new window. So I could use one main Document for coding, and the rest is just Templates... don't think to far. I think that this should work but the parametrs must be correct.
Me.Application.Documents.Add("Template_01.doc")
xlx2
Hi Thomas,
The Add method, is described in Help as follows:
Returns a Document object that represents a new, empty document
added to the collection of open documents.
It doesn't add the document to your existing document; rather it creates a new document as a separate document. This is very similar to using File, New to create a new document (or optionally base it on an existing template).
It sounds like what you want is an actions pane that can be used with multiple documents. Unfortuantely, that is not supported in VSTO. The actions pane can only be associated with the document or template that you used when you created your solution. I have blogged about a possible solution (simulating an application-level task pane) that describes inserting a document into an existing solution. See http://blogs.msdn.com/vsto2/archive/2005/09/08/462451.aspx for more details.
I hope this helps!
Kathleen
http://blogs.msdn.com/vsto2/