Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using the Actions Pane, Host Controls, and Smart Tags

Similar presentations


Presentation on theme: "Using the Actions Pane, Host Controls, and Smart Tags"— Presentation transcript:

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

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

3 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

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

5 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 Actions Pane control gives a nice design-time experience Globals.ThisWorkbook.ActionsPane.Controls.Add (New DateTimePicker)

6 Create a Simple Actions Pane

7 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

8 Managing Control Layout

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

10 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.

11 Host Control Features Extends Office object model
Properties and methods Richer event model WinForms style data binding Simplifies programming model

12 Automating Excel without Host Controls

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

14 Host Controls in Excel Chart ListObject NamedRange XMLMappedRange

15 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. XMLMappedRange controls Use the XML Source task pane

16 Using Excel Host Controls

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

18 Host Controls in Word Bookmark XMLNode

19 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

20 Using Bookmark Host Controls

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

22 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

23 Managing Dynamic Controls
Controls collection references static and dynamic controls Create dynamic controls with methods of the Controls collection Managed controls: AddButton, AddTextBox Host controls: AddBookmark, AddListObject, AddNamedRange You cannot dynamically create XMLNode or XMLMappedRanges controls You can only remove dynamic controls (not static) from the Controls collection at runtime

24 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 NamedRange control, the data in the cells remains If you delete a Bookmark control, the contents of the bookmark remains

25 Dynamic Host Controls

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

27 SmartTags Overview What is a SmartTag? What makes up a SmartTag?
Context Based Actions What makes up a SmartTag? Recognized Text Actions

28 Developing VSTO SmartTags
Steps: Create a SmartTag instance Add strings to recognize Add actions Register SmartTag object with the document

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

30 Create a SmartTag Instance
Constructor Parameters SmartTag type Caption SmartTag myTag = new SmartTag (" "Product Info");

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

32 Add Actions Create Action objects Set Caption property
Excel: Microsoft.Office.Tools.Excel.Action Word: Microsoft.Office.Tools.Word.Action Set Caption property Action action1 = new Action("Reorder"); myTag.Actions = new Action[] {action1} ;

33 Add Action Click Event Create Click event for action
action1.Click += new ActionClickEventHandler(action1_Click); void action1_Click(object sender, Microsoft.Office.Tools.Excel. ActionEventArgs e) { // TODO: Add Event Handler Code }

34 Register SmartTag with Document
VstoSmartTagsCollection Excel: ThisWorkbook class Word: ThisDocument class // In ThisWorkbook.cs this.VstoSmartTags.Add(myTag);

35 Smart Tags

36 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 SmartTags to augment your UI based on document content

37 Next Steps Participate in our newsgroups and web forum
microsoft.public.vsnet.vstools.office microsoft.public.officedev microsoft.public.office.developer Participate in VSTO-related blogs Team blog: VSTO MVP Chris Kunicki’s blog: Attend a free chat or webcast

38 For More Information Visit the VSTO sections of these MSDN® Developer Centers Office Developer Center Smart Client Developer Center VSTO Help documentation on MSDN

39 Questions?

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

41 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

42 XMLMappedRange 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 XMLMappedRange host controls for each mapped cell Almost same as the NamedRange Host Control. Provides you direct programmatic access to the Range that is mapped to XML.

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

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

45 Outlook Task Add-in Solution


Download ppt "Using the Actions Pane, Host Controls, and Smart Tags"

Similar presentations


Ads by Google