Using the Actions Pane Host Controls and Smart
- Slides: 45
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 Host Controls Dynamic Controls Smart Tags
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 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 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
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
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 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. Forms style data binding Simplifies programming model
Automating Excel without Host Controls
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
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
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
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
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 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 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 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
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 a Smart. Tag? Recognized Text Actions
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. 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. 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. 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. 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. 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: This. Document class // In This. Workbook. cs this. Vsto. Smart. Tags. Add(my. Tag);
Smart Tags
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 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 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?
© 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 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 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. 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 Add custom controls to custom forms
Outlook Task Add-in Solution
- Definitive host vs intermediate host
- General controls vs application controls
- He who controls the past controls the future
- Actions pane 3
- Street smarts vs book smarts
- One smart man he felt smart
- Interserf
- Smart shopping everfi
- It's not how smart you are
- What is the next letter? a z b y c x d
- Street smart vs book smart quotes
- One smart man he felt smart
- Host country and home country
- Smart sensor networks using bluetooth
- Ic card smart prepaid energy meter
- Hình ảnh bộ gõ cơ thể búng tay
- Ng-html
- Bổ thể
- Tỉ lệ cơ thể trẻ em
- Gấu đi như thế nào
- Tư thế worm breton là gì
- Chúa sống lại
- Các môn thể thao bắt đầu bằng từ đua
- Thế nào là hệ số cao nhất
- Các châu lục và đại dương trên thế giới
- Công thức tính độ biến thiên đông lượng
- Trời xanh đây là của chúng ta thể thơ
- Mật thư tọa độ 5x5
- Phép trừ bù
- Phản ứng thế ankan
- Các châu lục và đại dương trên thế giới
- Thơ thất ngôn tứ tuyệt đường luật
- Quá trình desamine hóa có thể tạo ra
- Một số thể thơ truyền thống
- Bàn tay mà dây bẩn
- Vẽ hình chiếu vuông góc của vật thể sau
- Thế nào là sự mỏi cơ
- đặc điểm cơ thể của người tối cổ
- Giọng cùng tên là
- Vẽ hình chiếu đứng bằng cạnh của vật thể
- Vẽ hình chiếu vuông góc của vật thể sau
- Thẻ vin
- đại từ thay thế
- điện thế nghỉ
- Tư thế ngồi viết
- Diễn thế sinh thái là