VSTO & .NET & Excel

August 31, 2007

Providing Form-Based help for Managed COM Add-ins

Filed under: .NET & Excel, COM Add-ins, VSTO & Excel — Dennis M Wallentin @ 3:20 pm

All my managed COM Add-ins solutions extensively use Windows forms. With .NET it’s very easy to create help that are directly associated with Windows forms which I hope this blogpost also will show.

For all my solutions I use complete helpfiles (.chm) created and compiled with RoboHelp  which is also used here. A compiled helpfile consists of several HTML files and the common term for these files is “topics”. Usually I place the helpfiles in the same directory as the solutions are placed in.

Basically Form-based help means that a specific topic is associated with a specific Windows form.

The following screenshot is from RoboHelp and shows the list of topics for a help project. For the case here I will be using the topic “Move Database” (its filename is Move_database.htm).

helptopics.png

In order to add Form-based help we need to add an instance of the HelpProvider to the Windows form. Like the ErrorProvider and other providers the HelpProvider is added to the Windows form’s component tray as the following screenshot shows:

helpprovider.png

When adding the component to the Windows forms five new properties are added to the form’s properties:

  • Help button:
    True if we want to add a help button to the Windows form’s caption bar to the right.
  • HelpKeyword on HelpProvider:
    Determines the Help keyword associated to the form or to the control. Here we refer to the topic filename as the below screenshot shows.
  • HelpNavigator on HelpProvider:
    Determines the kind of Help associated with the form or the control. Here we set it to Topic.
  • HelpString on HelpProvider:
    Determines the Help string associated with the form or the control. Here we leave it empty.
  • ShowHelp on HelpProvider:
    Determines if help is available or not for the form or for the control. This property should always be set to True. 

The following screenshot shows the first four properties’s settings:

helpsettings.png

When the Windows form has been loaded and has the focus the HelpProvider component starts to monitor the Windows form. When the end users press the F1 key the named topic is loaded in its own window. 

In the property window for the HelpProvider we also need to add the filename to the HelpNamespace:

help.png

What should be notable is the following:

  • No code is used to get the above solution.
  • In .NET we can refer to topics and are not forced to use TopicIDs.
  • No code or any settings are used to hook the help to the F1 key.
    It can be discussed whether the use of F1 key is the best approach or not. A help button can be a better solution under some other conditions.
  • For Windows forms that have multiply purposes the Form-based help approach should be replaced with a Control-based approach.

To see the final result of the above please see helpaction.png

Kind regards,
Dennis

August 30, 2007

Great COM Add-ins examples

Filed under: .NET & Excel, COM Add-ins, VSTO & Excel — Dennis M Wallentin @ 12:47 am

In MS Outlook it’s not possible to create native Add-ins as we can do in Excel. The only way is to create managed & unmanaged COM Add-ins. The first program that it was possible to create VSTO Add-ins for was Outlook. In my opinion these circumstances has lead to a situation where the group of professional Outlook developers has taken the lead when it comes to developing COM Add-ins.

One of the well known Outlook developers in the online community is Ken Slovak and his latest book Professional Outlook 2007 Programming (or at Wrox’s site) will soon be available. The projects and templates that are used in the book has the publisher (Wrox) agreed to make available for public download.

For some days ago I downloaded the VB.NET / VSTO 2005 SE projects and samples and spent time to evaluate them. Although we may not be interested to develop Add-ins for Outlook I find them to be great examples for creating robust and reliable managed COM Add-ins projects.

The projects and templates are available for download from Ken’s site:
Outlook 2007 Projects & Templates

Kind regards,
Dennis

August 21, 2007

Security policies and settings in the 2007 Office system

Filed under: .NET & Excel, COM Add-ins, VSTO & Excel — Dennis M Wallentin @ 7:42 pm

Microsoft has recently published a good and interesting paper on security in 2007 Office. This is the most comprehensive and exhaustive online source I have seen on the subject. I suggest that you print it out and read it carefully:

Security policies and settings in the 2007 Office system 

Kind regards,
Dennis

FolderBrowserDialog and Managed COM Add-ins

Filed under: .NET & Excel, COM Add-ins, VSTO & Excel — Dennis M Wallentin @ 5:51 pm

I’m working with the new version of .NET Connection Tool and discovered an odd thing. In a Windows Forms I have added a FolderBrowserDialog enabling users to select a new folder to move the Access database to.

The code in use is the following:

folder.png

As you can see the code disables the button to create new folders with. When using it in Windows Vista & Excel 2007 the folder browser’s form is showed correctly as the following image shows:

2k7.png 

With Windows XP and Excel 2002 and Excel 2003 it also works properly. However, when using it in Windows 2000 & Excel 2000 the option to create a new folder is now available:

2k.png

Since I’m not been able to resolve it myself I wonder if anyone know how to solve it so that the button New Folder is also not available in Excel 2000?

Kind regards,
Dennis
 

August 4, 2007

Adding (missing) Ribbon’s controls

Filed under: .NET & Excel, COM Add-ins, VSTO & Excel — Dennis M Wallentin @ 5:06 pm

Nowadays I primarily use Excel 2007 and I must say that I really like the Ribbon UI which I also find easy to use. Given that the focus is on end users and their ability to use Excel toolbox it’s understandable that the Ribbon and RibbonX do not support the group of developers. At least not for the 1.0 “version” of the Ribbon UI.

When I’m not using the Excel Loader I find myself many times in situations where I need to have access to the two built-in Add-ins managers (for XLAs respectively COM). They are not easy to access via the Excel Options button. Therefore I have customized the Developer’s tab enabling me to access them better when needed. Of course, it would perhaps be even better if I used keyboard’s commands to access them. 

Maybe I’m wrong but I would say that they per default should be available under the Developer’s tab.

The following image is a screenshot of the customized tab:

  

TabDeveloper

The XML for the above customization is quite simple: 

XML

Since I’m a power user of Add-in Express 2007 for Microsoft .NET I decided to create the same Ribbon customization in a managed add-in. This is done without a single line of code as the following steps will show:

Step 1 – Adding a Ribbon Tab object to the project:

ribbon.png


Step 2 – Configure the Tab

Since we don’t add a new tab to the project we instead refer to the built-in Developer’s tab:

ribbon1.png


Step 3 – Add a group to the tab

The following image shows the configuration of the added group:

ribbon2.png


Step 4 – Add controls
 

Since we want to use the built-in controls we refer to them when configure the added controls as the following image shows:

ribbon3.png

When running the managed add-in with Excel 2007 it adds the above customization. When we run the managed add-in with Excel 2003 or earlier we don’t need to take any further action to prevent it from being loaded.

I hope that I in my next blogpost can present the new and updated version of .NET Connection Tool.

With kind regards,
Dennis

Blog at WordPress.com.