Insert outlook 2007 button within menu in C#? - c#

In Outlook 2007 you have the navigation panel, consisting of "Mail","Calendar","Contacts","Tasks" etc (this is all below the tree structure).
1) Is it possible (and if so, how?) to insert another user-defined button between, say, "Mail" and "Calendar"?
2) Programatically, how could I minimise the main pane? So if I was in "Mail", the main pane would be "Inbox".
I have been using Add-in Express for customisation, but I dont believe it can do the above and could be a general .NET question.

Do you mean create an additional button inside Outlook, or reuse the button styles/etc in a 3rd party application?
If you mean inside Outlook, then yes, Outlook 2010 (not 2007) provides some OM hooks to add 1 additional button here. It's called the Solutions module. If there is only one solution installed, the name of the button takes the title of the solution. If there are multiple solutions then the title reverts to "Solutions"
If you mean outside of Outlook, then no. It's not possible. These buttons are not COM components (in fact, they're not even proper HWNDs).

1.) You cannot create new Navigation Modules in the Navigation Pane. See MSDN forums for related question.
2.) An Outlook View Control will let you takeover the currently active view pane.

Related

Is there a workaround or alternative to IRibbonControl.Context to access the correct window and workbook in Excel 2016 or newer?

There are existing posts on SO about related topics, and there are support requests on MSDN that are unsolved/unrepaired. It sounds like the "right way" doesn't work, so I'm wondering there is a workaround.
Let me describe what I perceive to be "the right way" that doesn't work, and maybe you have an alternative path that will work.
I can create an Excel VSTO plugin in Visual Studio, create a custom Ribbon.xml and Ribbon.cs file, and then open multiple workbooks which appear as different windows. Per other SO posts, I can hook into the Application_WindowActivate event and call Invalidate() on my ribbon, forcing a refresh of all the callbacks. The ribbon will reflect the state of the Active Window... and so will every other instance of the ribbon in other windows. As a result, the Ribbon that appears in every window is the same Ribbon. If I have a CheckBox or a Button with a Pressed attribute or anything else stateful, those states will propagate to every open Excel window.
This can be avoided by running Excel with the excel /s parameter which appears to create a new process with its own SDI - but this is not a user-friendly solution.
It looks like what you're supposed to be able to do during an onAction ribbon callback is access the IRibbonControl parameter's Context property, which is supposed to be the correct Excel.Window object. In theory this would present either only the Window you are activating, or would execute for each open Window. And with the correct Context you could execute functions that provide different states back to the Ribbon. And then maybe in one Excel window, you ribbon could have a Pressed Button, and in the other window, an unpressed Button. Except it doesn't work.
When I call Invalidate I get two callbacks (not sure why, the MSDN says it might be a bug) both for the newly activated window, and I execute logic to update the state of active window's ribbon. And then the previous window's ribbon updates the same way.
If this is the way it is, fine. We'll tell our users that they may see some funky Ribbon changes on inactive windows but that it will always be correct on the active window. We can deal with that. But if there is a way around this problem that could make it appear as though the Ribbon had different states on a per-workbook/window basis... that'd be really cool.
You are on the right avenue. Only the active window gets callbacks invoked and its values refreshed. You must switch to another Excel window if you want your ribbon UI invalidated. For each of the callbacks the add-in implements, the responses are cached. For example, if an add-in writer implements the getImage callback procedure for a button, the function is called once, the image loads, and then if the image needs to be updated, the cached image is used instead of recalling the procedure. This process remains in-place until the add-in signals that the cached values are invalid by using the Invalidate method, at which time, the callback procedure is again called and the return response is cached. The add-in can then force an immediate update of the UI by calling the Refresh method.
You may also consider caching UI settings in custom properties. And as soon as a custom property is changed you may trigger UI updates.
Read more about the Fluent UI in the following series of articles:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
Also, you may find the folliwing links helpful:
Chapter 11: Creating Dynamic Ribbon Customizations (1 of 2)
Chapter 11: Creating Dynamic Ribbon Customizations (2 of 2)

Best way to control Word from Windows Forms?

I am updating a Windows Forms application that was written for Office 2003. It would open Word, populate it with text from the database, create buttons appropriate for the user's security roles, and handle button clicks. The old way was with CommandBars. The Word documents created this way were stored as DB Blobs, so they were only ever available via the Forms application. That is the functionality I need, but without CommandBars.
Now, we have the Ribbon, Action Panes, VSTO, and OpenXML. I know my way around C#, but I'm new to all of these technologies.
I imagine a solution where I set up a template with the proper buttons on a nice ribbon, and the buttons raise events. If someone just tried to use the template by itself, there would be no data and the events would do nothing. But my Windows Form could create a new document based on the template, populate it with text from the database, hide inappropriate buttons, and handle button click events. Easy peasy.
I began by adding a Word 2010 Template project and making a ribbon for it. It looks nice in the debugger. But, I can't create a new document with it from a Console app. Word launches, but the ribbon isn't there. There's a note in the documentation that "If a Microsoft Office Word template has managed code extensions, the project assembly is not called if the template is attached as a global template or loaded from the startup directory of Word. In addition, the document does not recognize the format of a template that is part of an Office solution." I believe this means my template is useless. I can't open Word and make a new document with my template or call the template from another project, so, pointless.
All the MS help has failed me, and mostly leads me in circles. I need some direction. For each piece of the scenario I described, what is the most appropriate modern technology? For each technology I need to use, what is the best resource for my situation?

Why is my workflow not showing all the steps?

I created a workflow in Microsoft Dynamics CRM 2011 which I then exported and opened the XAML file with VS 2010. It shows me this when I open it:
But there are actually many more steps in this workflow. Why can't I see them or edit them? I tried clicking Expand All at the top right, but that didn't seem to make any difference. If I look at the actual code I can see the numerous steps - but no in the design view. Any ideas why?
The activities in your screenshot are custom activities. By default all you see is this placeholder. You can however create custom activity designers and associate the activities with those. In your custom activity designer you can do anything you can do in WPF including showing the child activities.

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.

C# Outlook Addin w/ WPF

I have looked at several tutorials on writing general Outlook add-ins, and have gotten simple examples to work: items in menu, context menu, ribbons, etc.
Many of Microsoft's documentation has send me in circles, or is in VB, so I have run into some questions with what we are trying to accomplish.
Is there a way to add a custom control below the Subject line in a new email? We need to supply a drop-down and add an additional header to emails sent for email tracking. Right now the best I have gotten is adding a CommandBarButton in the "Add-ins" tab of the Ribbon, is there a better method?
Will we run into any issues installing for multiple versions of outlook? (Will only 2007 and higher work?)
Can you host WPF controls directly in a Ribbon, etc.? I know that WPF popup windows work just fine when shown from a CommandBarButton.
Are there some good links out there for what we're trying to do?
2: Multi-version support is a PITA. The hedge-your-bets approach is to develop on a PC running the version of Outlook you want to support; thus you may have multiple setup packages for each supported version. Everybody tries to get around this though, but I've used this approach with success:
Version-Specific UI in Add-ins - Andrew Whitechapel - Site Home - MSDN Blogs:
http://blogs.msdn.com/b/andreww/archive/2008/09/02/version-specific-ui-in-add-ins.aspx
4: Essential resources:
Visual Studio Tools for Office For Office and Outlook for Developers Forums on MSDN
OutlookCode.com
(FYI, I work for Add-in Express)
No, not without implementing the entire message window.
We have to make 2 projects for 2007 and 2010, we are skipping 2003 and below b/c it is much more difficult and would be rarely used.
Can't host WPF in a Ribbon, we're going to display a WPF popup from a Ribbon button press.
Best thing I've found is to just follow the project template in Visual Studio and mess around.
Overall, our add-in is going to do the following:
Make 2 projects for 2010 and 2007 that share a "Shared" assembly
All reusable work is done in the shared assembly
WPF is only displayed via popup windows (you can do a custom task pane, but it doesn't make sense for our add-in)

Categories

Resources