Using the Actions Pane Host Controls and Smart

  • Slides: 45
Download presentation
Using the Actions Pane, Host Controls, and Smart Tags Donald Drake Development Manager Visual

Using the Actions Pane, Host Controls, and Smart Tags Donald Drake Development Manager Visual Studio Tools for Office

Agenda Actions Pane Overview Managing Control Layout Host Controls Overview Excel Host Controls Word

Agenda Actions Pane Overview Managing Control Layout Host Controls Overview Excel Host Controls Word Host Controls Dynamic Controls Smart Tags

Actions Pane Overview Enables contextual UI complementary to the document Flexible way of designing

Actions Pane Overview Enables contextual UI complementary to the document Flexible way of designing custom UI Addresses UI layout challenges Plugs naturally into Office UI Acts like a toolbar: floating or docked

Actions Pane Technology Overview Smart Document SDK Actions Panes (VSTO) Requires ISmart. Document interface

Actions Pane Technology Overview Smart Document SDK Actions Panes (VSTO) Requires ISmart. Document interface implementation Requires XML expansion packs Requires XML-based document Not required. VSTO takes care of this implementation for you Not required. VSTO takes care of this for you Optional. You can create a solution that is not based on XML Supports Windows Forms controls Supports Active. X controls

Adding an Actions Pane Actions pane becomes visible when you add a control to

Adding an Actions Pane Actions pane becomes visible when you add a control to it Use Windows Forms controls, custom User controls or Actions Pane controls Globals. This. Workbook. Actions. Pane. Controls. Add (New Date. Time. Picker) Actions Pane control gives a nice design-time experience

Create a Simple Actions Pane

Create a Simple Actions Pane

Managing Layout Add multiple controls to the actions pane Change the stack order of

Managing Layout Add multiple controls to the actions pane Change the stack order of controls on the actions pane when the user changes the orientation of the actions pane Programmatically change the orientation of the actions pane Show and hide controls on the actions pane Show and hide the actions pane

Managing Control Layout

Managing Control Layout

Agenda Actions Pane Overview Managing Control Layout Host Controls Overview Excel Host Controls Word

Agenda Actions Pane Overview Managing Control Layout Host Controls Overview Excel Host Controls Word Host Controls Dynamic Controls Smart Tags

What is a Host Control? A type that extends the host application (Word or

What is a Host Control? A type that extends the host application (Word or Excel) Object Model to provide new functionality or to enhance programmability.

Host Control Features Extends Office object model Properties and methods Richer event model Win.

Host Control Features Extends Office object model Properties and methods Richer event model Win. Forms style data binding Simplifies programming model

Automating Excel without Host Controls

Automating Excel without Host Controls

Agenda Actions Pane Overview Managing Control Layout Host Controls Overview Excel Host Controls Word

Agenda Actions Pane Overview Managing Control Layout Host Controls Overview Excel Host Controls Word Host Controls Dynamic Controls Smart Tags

Host Controls in Excel Chart List. Object Named. Range XMLMapped. Range

Host Controls in Excel Chart List. Object Named. Range XMLMapped. Range

Creating Excel Host Controls Drag and drop host control from Visual Studio Toolbox Drag

Creating Excel Host Controls Drag and drop host control from Visual Studio Toolbox Drag and drop a data element from the Data Sources window that is mapped to a host control Use menus to add the underlying Excel object to a document. The VSTO designer creates a host control to wrap the Excel object being created. XMLMapped. Range controls Use the XML Source task pane

Using Excel Host Controls

Using Excel Host Controls

Agenda Actions Pane Overview Managing Control Layout Host Controls Overview Excel Host Controls Word

Agenda Actions Pane Overview Managing Control Layout Host Controls Overview Excel Host Controls Word Host Controls Dynamic Controls Smart Tags

Host Controls in Word Bookmark XMLNode

Host Controls in Word Bookmark XMLNode

Creating Word Host Controls Bookmark controls Drag/drop from Toolbox Drag/drop from Data Sources window

Creating Word Host Controls Bookmark controls Drag/drop from Toolbox Drag/drop from Data Sources window Click Bookmark on the Insert menu XMLNode controls Use the XML Structure task pane

Using Bookmark Host Controls

Using Bookmark Host Controls

Agenda Actions Pane Overview Managing Control Layout Host Controls Overview Excel Host Controls Word

Agenda Actions Pane Overview Managing Control Layout Host Controls Overview Excel Host Controls Word Host Controls Dynamic Controls Smart Tags

Dynamic Controls A control (managed or host control) added to the Word or Excel

Dynamic Controls A control (managed or host control) added to the Word or Excel document at runtime Enable you to create interactive documents because you can add controls in response to user input or events

Managing Dynamic Controls collection references static and dynamic controls Create dynamic controls with methods

Managing Dynamic Controls collection references static and dynamic controls Create dynamic controls with methods of the Controls collection Managed controls: Add. Button, Add. Text. Box Host controls: Add. Bookmark, Add. List. Object, Add. Named. Range You cannot dynamically create XMLNode or XMLMapped. Ranges controls You can only remove dynamic controls (not static) from the Controls collection at runtime

Dynamic Controls and Persistence Dynamic controls are not persisted Underlying data in dynamic host

Dynamic Controls and Persistence Dynamic controls are not persisted Underlying data in dynamic host controls may be persisted. For example: If you remove an Excel Named. Range control, the data in the cells remains If you delete a Bookmark control, the contents of the bookmark remains

Dynamic Host Controls

Dynamic Host Controls

Agenda Actions Pane Overview Managing Control Layout Host Controls Overview Excel Host Controls Word

Agenda Actions Pane Overview Managing Control Layout Host Controls Overview Excel Host Controls Word Host Controls Dynamic Controls Smart Tags

Smart. Tags Overview What is a Smart. Tag? Context Based Actions What makes up

Smart. Tags Overview What is a Smart. Tag? Context Based Actions What makes up a Smart. Tag? Recognized Text Actions

Developing VSTO Smart. Tags Steps: 1) Create a Smart. Tag instance 2) Add strings

Developing VSTO Smart. Tags Steps: 1) Create a Smart. Tag instance 2) Add strings to recognize 3) Add actions 4) Register Smart. Tag object with the document

Create a Smart. Tag Instance Create a Smart. Tag object Excel: Microsoft. Office. Tools.

Create a Smart. Tag Instance Create a Smart. Tag object Excel: Microsoft. Office. Tools. Excel. Smart. Tag Word: Microsoft. Office. Tools. Word. Smart. Tag Stores Recognizers Terms Collection Property Expressions Collection Property Stores Actions Array Property

Create a Smart. Tag Instance Constructor Parameters Smart. Tag type Caption Smart. Tag my.

Create a Smart. Tag Instance Constructor Parameters Smart. Tag type Caption Smart. Tag my. Tag = new Smart. Tag ("www. example. com#prod. Info", "Product Info");

Add Strings to Recognize Terms Collection Static strings Expressions Collection Regular expressions my. Tag.

Add Strings to Recognize Terms Collection Static strings Expressions Collection Regular expressions my. Tag. Terms. Add(“Tofu”); my. Tag. Expressions. Add (new Regex(“[A-Z]{1}[0 -9]{3}”));

Add Actions Create Action objects Excel: Microsoft. Office. Tools. Excel. Action Word: Microsoft. Office.

Add Actions Create Action objects Excel: Microsoft. Office. Tools. Excel. Action Word: Microsoft. Office. Tools. Word. Action Set Caption property Action action 1 = new Action("Reorder"); my. Tag. Actions = new Action[] {action 1} ;

Add Action Click Event Create Click event for action 1. Click += new Action.

Add Action Click Event Create Click event for action 1. Click += new Action. Click. Event. Handler(action 1_Click); void action 1_Click(object sender, Microsoft. Office. Tools. Excel. Action. Event. Args e) { // TODO: Add Event Handler Code }

Register Smart. Tag with Document Vsto. Smart. Tags. Collection Excel: This. Workbook class Word:

Register Smart. Tag with Document Vsto. Smart. Tags. Collection Excel: This. Workbook class Word: This. Document class // In This. Workbook. cs this. Vsto. Smart. Tags. Add(my. Tag);

Smart Tags

Smart Tags

Summary Create actions pane with one line of code Manage actions pane control layout

Summary Create actions pane with one line of code Manage actions pane control layout Host Controls give you the ability to rapidly develop powerful VSTO applications by providing: Simplified programming model Rich event model Winforms style Databinding Add controls to documents either at design time or run time Use Smart. Tags to augment your UI based on document content

Next Steps Participate in our newsgroups and web forum microsoft. public. vsnet. vstools. office

Next Steps Participate in our newsgroups and web forum microsoft. public. vsnet. vstools. office microsoft. public. officedev microsoft. public. office. developer http: //forums. microsoft. com/msdn/Show. Forum. aspx? Foru m. ID=16 Participate in VSTO-related blogs Team blog: http: //blogs. msdn. com/vsto 2 VSTO MVP Chris Kunicki’s blog: http: //www. officezealot. com/VSTO/ Attend a free chat or webcast http: //www. microsoft. com/communities/default. mspx

For More Information Visit the VSTO sections of these MSDN® Developer Centers Office Developer

For More Information Visit the VSTO sections of these MSDN® Developer Centers Office Developer Center http: //msdn. microsoft. com/office/understanding/v sto/default. aspx Smart Client Developer Center http: //msdn. microsoft. com/smartclient/understan ding/vsto/default. aspx VSTO Help documentation on MSDN http: //msdn 2. microsoft. com/library/d 2 tx 7 z 6 d(enus, vs. 80). aspx

Questions?

Questions?

© 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only.

© 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

Why extend Office OM? • To utilize the power of Word and Excel, we

Why extend Office OM? • To utilize the power of Word and Excel, we need to present most of the data in the document, not in Winform controls • Word and Excel Object Models expose types for this purpose • But the types exposed lack some features that. NET developers take for granted in Winforms

XMLMapped. Range Host Control Mapping cells in an Excel worksheet to an XML Schema

XMLMapped. Range Host Control Mapping cells in an Excel worksheet to an XML Schema is a feature provided by Excel. When you map an Excel worksheet to XML, VSTO creates instances of XMLMapped. Range host controls for each mapped cell Almost same as the Named. Range Host Control. Provides you direct programmatic access to the Range that is mapped to XML.

Adding Bookmark at Run Time private void bookmark. Example() { Microsoft. Office. Tools. Word.

Adding Bookmark at Run Time private void bookmark. Example() { Microsoft. Office. Tools. Word. Bookmark bookmark 1 = this. Controls. Add. Bookmark( this. Paragraphs[1]. Range, “bookmark 1”); bookmark 1. Text = “Sample bookmark text. ”; }

Outlook Solutions Add custom menu with buttons to standard menu bar Display custom forms

Outlook Solutions Add custom menu with buttons to standard menu bar Display custom forms Add custom controls to custom forms

Outlook Task Add-in Solution

Outlook Task Add-in Solution