Multiple instances of Word Add-In - c#

I've developed an application-level add-in for Word, and encountered the following problem:
When another document is opened (and another Word Window appears), I cannot use the Add-In in the newly-opened window. Moreoever, when I click the button in the Ribbon that should display the Add-In, it's getting displayed in the original window, and not the new one.
How can I make the Add-In appear also in the new Window?
Thanks!
UPDATE: After realizing the question was not clear enough, let me clarify:
The Add-In displays custom task pane.
What happens is that when I open a new window of Word, the button that displays / hide the pane affects only the original window, and not the new one, so I cannot display two instances of the task pane.
Why is that? How can I display multiple task panes in Word?

That's becuase TaskPane is document bound object. If you create your TaskPane in Addin_Startup it will be bound to the active document. While having two instances od Word Document, you have that Active document still opened, so any button on Ribbon (which is shared between instances) will only affect that first window.
The solution is problably to create multiple TaskPanes for multiple documents, but that's kinda ghetto solution.

Related

Getting out of the Add-Ins window

I was able to produce an add-in, which provides two user interfaces. However they are shown as tabs in the Add-Ins window. Earlier I worked with a single control and this one has been shown in its own window.
They both have different GUIDs and are registered COM objects. I initiate like this:
control1 = GuiManager.Repository.AddWindow("Quick Interface Editor", "QuickInterfaceEditor.QuickInterfaceEditorControl") as QuickInterfaceEditorControl;
control2 = GuiManager.Repository.AddWindow("Tagged Values Editor", "TaggedValuesEditor.TaggedValuesEditorControl") as TaggedValuesEditorControl;
Is there a way to bring both tabs to their own windows? Or at least replace the "Add-Ins" title by my add-in's name?
There are basically three ways to show a window as an add-in
Repository.AddWindow()
This adds an add-in window in the add-ins docked window. If this is the only add-in window that uses this section, than the docked window will get the title from the add-in window.
If there are multiple add-ins, the title will be Add-Ins and each add-in will get a tab, like you noticed with your add-ins.
Repository.AddTab()
This adds a window to the main diagram space
Form.ShowDialog() or Form.Show()
This allows you to show a model dialog, or regular window on top of EA's GUI

Disabling applications for form tasks (C#)

I'm creating an add-in for Microsoft Excel that helps to automate some of my accounting processes. One of the pieces of the add-in is a ribbon tab with a button. Clicking this button opens a form with a list box that displays each account (worksheet) name and their respective balances.
The problem is that the rest of the controls in Excel are still tangible while the form is open. If, for example, a person were to change the name of the worksheet while the form was open, it may cause an error.
I noticed that message boxes render an application unclickable until they exit the screen. It isn't limited to just message boxes, either- I've seen the Nexus Mod Manager do the same thing when installing mods for games. I've seen it in many applications, but I haven't figured out how to do it myself.
My question is simple: how do I change the properties of a form such that the rest of the application is disabled until the form is closed?
What you need is a modal form. Opening a modal form will "block" the entire UI until it is closed, just like message boxes do.
Have a look at http://msdn.microsoft.com/en-us/library/aa984358(v=vs.71).aspx

Trigger a call to IRibbonExtensibility.GetCustomUI() to force a ribbon UI refresh

I am developing an Office add-in. Due to some limitations of ribbon controls (e.g. menuSeparator has no visibility control or splitButton cannot host a dynamicMenu only a menu), I need to be able to cause the Office app to reload the ribbon by repeating a call to my add-in's IRibbonExtensibility.GetCustomUI.
Is this possible?
As far as I know ribbon add-ins, this would require to stop and then restart your add-in. There must be a way to do so given that one can access the list of add-ins in outlook. you could run another instance of your add-in which would first close the previous one, then return the updated ribbon XML. But this means that it would not be applicable while the user is clicking on the ribbon's components, and you would have to save all your data somewhere and then read it to restore the add-in status. In addition, the user may see the ribbon disapearing and appearing again, which may not be appreciated.
Would the Ribbon.Invalidate() method work for your use case? I frequently use it to refresh the ribbon when I've dynamically added/removed items.
For example, in the Ribbon c# file (Ribbon1.cs by default):
this.ribbon.Invalidate();
When the ribbon needs to be refreshed. This assumes you've set this.ribbon in the Ribbon_Load method.

Can you open a form or window in an Outlook Addin (VSTO)

I am new to VSTO programming. I have created a basic addin for Outlook 2007 that monitors a folder containing XML text files which it opens and then sends them as an email, then deletes them. this all works fine.
I want the user to be able to configure certain settings for the way the addin/program will operate, such as the folder that it will monitor, and other things. The logical way to do this is to create a menu item in the addin (which I have also done) that opens a windows form (or XAML window) that allows them to enter the parameters.
In my addin I added a new item Windows Form, which worked, and the designer opened. However, in my addin code I cannot open the form. The Show() method normally associated with form objects is not available.
Is this simply something you cannot do, or am I just doing it the wrong way?
I have read about Outlook form regions, but these seemed to be attached to outlook items such as a new email, task, appointment etc... there doesnt seem to be a way to create a form region that can be opened in the main window of Outlook.
Ideally, I would like to go with my original method of opening a new window from a menu item, but if this isnt possible I would like to hear other solutions.
Thanks,
Will.
For a normal form, it sounds like you didn't just add System.Windows.Forms as a reference,
create the object then show it eg.
Form myFrm = new frmFlightList();
myFrm.Show();
This should work in a VSTO addin, as it does in any other form. The CMSConnectorControl object you refer to is a distraction to others for the general case of just wanting to display a form.
figured this out, After I built my form I just had to add these lines
CMSConnectorControl formMain = new CMSConnectorControl();
formMain.ShowDialog();
to the ThisAddin_Startup() function.

VSTO - Outlook 2007 How do I show a form inside the Outlook window?

I'm using VSTO with Outlook 2007 and I need to show a form (or a user control) inside the main window in outlook when the user clicks a specific toolbar button, that is, I need it to appear in the same window that the reading pane appears and not to open in a window by itself. Is this possible?
Thank you for your time.
Yandos,
you can do this using Subclassing, this can be a complicated subject but a great primer is over at http://www.codeproject.com/KB/office/additional_panel_Outlook.aspx
or you could use a comercial product that does that for you e.g, add-in-express
Yes, you can create an Outlook Form Region. Here's one of the many resources available on the subject:
Walkthrough: Creating an Outlook Form Region
http://msdn.microsoft.com/en-us/library/aa942741(VS.80).aspx

Categories

Resources