Using Word Dialogs programmatically: C# sample
This blog is about a sample add-in project (with source code) demonstrating how to use Word dialogs programmatically. With this add-in you can:
- check if a given dialog is suitable for your task
- get version-specific information about that dialog and its properties
Microsoft Word contains a lot of built-in dialogs; there are 238 of them in Word 2010! Although the whole feature seems to be abandoned, it looks like many dialogs can be used. Run this add-in to check if any given dialog is okay.
The UI of the add-in is built into an Advanced Word Task Pane. You specify a Word version (#1 in the screenshot), choose a Word dialog (#2), set a property (#3) and click an action button (#4) to invoke a method that the Word.Dialog interface provides.
Many dialogs provide properties e.g. the dialog identified by the constant wdDialogConnect provides the properties Drive, Password and Path (see the screenshot). Dialog properties are accessible via late binding only, see code samples in How to: Use Built-In Dialog Boxes in Word on MSDN or pay attention to the property WdBuiltinDialogProperty.Value in the code of this add-in. Properties names are published in MSDN. They are also available in the code of the add-in.
Word Dialogs: Backward compatibility issues
You should know that Office applications are almost 100% backward-compatible. Dialog properties is the area where backward compatibility gets broken too often. The list of properties existing in every Word version of every Word dialog is contained in the constructor of the WdBuiltinDialogs class, see the code of the add-in.
These sample COM Add-ins were developed using Add-in Express for Office and .net: