Presentation is loading. Please wait.

Presentation is loading. Please wait.

Managed Code Development and Microsoft Office Mike Pelton Stephen Turner Developer & Platform Group Microsoft.

Similar presentations


Presentation on theme: "Managed Code Development and Microsoft Office Mike Pelton Stephen Turner Developer & Platform Group Microsoft."— Presentation transcript:

1 Managed Code Development and Microsoft Office Mike Pelton MPelton@microsoft.com Stephen Turner STurner@microsoft.com Developer & Platform Group Microsoft Ltd.

2 The slides for this event will be posted at: www.microsoft.com/uk/msdn/postevents

3 MSDN Connection Get personalised info and a customised RSS feed The programming language(s) you’re interested in The technology area(s) you’re interested in The information you want View news, technical resources, events, webcasts and community information Sign up for MSDN Connection at: http://www.microsoft.com/uk/msdn

4 Microsoft Technical Roadshow http://www.microsoft.com/uk/techroadshow April 12 th – 13 th Edinburgh Corn Exchange

5 Agenda 9:30 – 9:45 Introduction 9:45 – 11:00 Office and Managed Code (1) 11:00 – 11:15 Break 11:15 – 12:30 Office and Managed Code (2) 12:30 – 13:30 Lunch 13:30 – 14:45 Windows Forms II 14:45 – 15:00 Break 15:00 – 16:15 Deployment and Security

6 Smart clients are easily deployed and managed client applications that provide an adaptive and interactive experience by leveraging local resources and intelligently connecting to distributed data sources. Web Services & Offline/Online support Device Adaptability Tough to Deploy Heavy Footprint DLL Hell Network Dependency Poor User Experience Rich UI Complex To Develop Rich User Experience Developer Productivity Responsive Broad Reach Easy Change Management Ease of Deployment

7 General Information Work Flow Storage Server process XML, data or documents Microsoft Office 2003 Development Technologies Office programs Create content Analyze/review information Process documents Server Processing Create document Pre-populate template Search / extract Post-Office Processing Business workflow Collaborative work Publish/distribute/archive assistive core content Storage Server process Office U.I. Custom controls / U.I. Smart tags Smart documents XML schema Data binding Object models Research task pane Doc. actions task pane User Interaction Base Programmability XML Documents Data Post-Office Processing Web services IBF Research services ADO.NET Web queries Information Access XML VSTO v2005 data island Server-side Processing

8 Morning Agenda (!!) A Plethora of Techniques The Research Pane Smart Tags Smart Documents XML in Office Visual Studio Tools for Office VisioInfoPath The Information Bridge Framework Visual Studio 2005 & Office

9 Office Products are COM Servers Whatever happens, you’re bridging between your managed and Office’s unmanaged code Normal interop procedures and considerations apply! Primary Interop Assemblies Platform Invoke Using methods from unmanaged DLL’s Reflection Discovering the types to use at run-time Connecting to running instances Use P/Invoke to find running instances Using Accessible objects IAccessible interface increases accessibility to users AND code

10 Excel Primary Interop Assembly

11 Integrating Managed Code Calling managed code from VBA Programming the VB Editor (!) Using Windows Forms inside Office apps Using MIME Types COM Drag and Drop

12 Calling Managed Code from VBA COM Callable Wrapper (CCW)

13 Using MIME Types

14 Using Windows Forms

15 Drag & Drop

16 Add Ins VBA Add Ins Easy to develop, but slow and vulnerable Excel XLL’s, Word WLL’s Fast in execution; small skill pool COM Add-Ins Fast; require COM skills Office 2000 or later Automation Add-ins Functions can be called from Excel formulas Excel XP or later

17 A Simple Add In

18 All the books you’ll ever need: Microsoft.NET Development for Microsoft Office By Andrew Whitechapel

19 Office 2003 Research Library Searches information sources from within a document Returns rich content, forms, actions Open architecture via XML Web Services Registration and Query methods No code on the client Integrated across Office 2003 Word, Excel, PowerPoint, Outlook, etc. A number of out-of-the-box services Dictionary, etc.

20 Built-in Services Local sources on the machine Thesaurus and translation Office 2003 research services Dictionary, encyclopedia, web search, stock quotes Partner research services Factiva, eLibrary, Gale, WorldLingo More are being added SharePoint Portal Server

21 Custom Services Can build custom research services Development language and platform neutral Data agnostic If you can connect to it programmatically, the research pane can talk to it Based on established API Documented in Research Service SDK Uses Web Services and published XML Schemas for communication between Office and your research service

22 Web Server Registration Request Registration Response Query Request Query Response Web Service Calls Registration and query

23 Research Services Summary Just one Web Service, with two web methods Communications based on published Schema Transport via HTTP and SOAP Message bodies No assumptions about backend Can be developed with any Web Service development environment Connect to SQL Server, Oracle, MySql, SAP, MainFrame, etc.; You control the code! Extend client with Smart Tags (optional)

24 A Simple Research Service

25 A Better Way To Build Research Services Research Services Object Model Wrapper Simple library that wraps up the research services plumbing Provides strongly typed request and response objects for Registration() and Query() Allows developer to focus on business logic Source code available Managed code written with C# &.NET Framework 1.1 Allows for extensibility

26 The IBuySpy Research Service

27 Smart Tags v2 Innovations Across All Office Applications Appears in more Office places: Access, PowerPoint, Outlook & Task Panes Internet Explorer (with tool from SDK) Innovations: Auto firing actions (to modify document) Cascading menus & dynamic menus Pattern matching without writing code Smart tags for XML Tokenization – huge benefit for Asian languages

28 Smart Documents Task Pane User Reactive Guided Solutions Follows the user through the document Tightly integrated with XML schema mapping Provides contextual content, actions & help Customizable through VB6 or VS.NET Extension of the Smart Tags 2.0 API Secure auto deployment & update Highly secure, manifest-described deployment Document only contains the URL of the manifest Centralized versioning and self-maintaining

29 A Simple Smart Document

30 XML Schema Anatomy Of A Smart Document Solution Document XML Schema XML Manifest is identified by Solution URL Manifest describes the XML Expansion Pack files Code, images, data Document XML Manifest name address dllimageschemaconfig Solution URL

31 The Document Word 2003 or Excel 2003 Configuration tool sets XML Expansion Pack association Word: Tools > Templates and Add-ins Excel: Data > XML > XML Expansion Packs

32 The XML Schema.XSD file An element identifies an active region Document Action pane can be customized per element

33 The XML Manifest Describes the XML Expansion Pack for this Smart Documents solution Version Update policy Files “Action Handler” code identity CLSID (COM) CLSNAME (.NET)

34 Action Pane Layout Flow layout (like HTML) but… Only one control per line Background always white Control types (C_TYPE_) ACTIVEXBUTTONCHECKBOXCOMBODOCUMENTFRAGMENTDOCUMENTFRAGMENTURLHELPHELPURL IMAGELABELLINKLISTBOXRADIOGROUPSEPARATORTEXTBOXControlArray

35 The Code (Action Handler) Code loaded by the host (Word/Excel) For each document region identified by an element in the XML schema Renders the Document Actions pane UI Handles users interaction with the controls in the Document Actions pane

36 Coding Smart Documents Programming languages support COM: Visual Basic 6.0, Visual C++.NET: Visual Basic.NET, C# Microsoft Office Smart Tag List (MOSTL) No Visual Basic for Applications Support Implement the Smart Document API ISmartDocument (COM).NET code can use Office PIAs

37 ISmartDocument Not event driven or object oriented Your code must handle many low level details Case logic, numeric IDs make complex solutions difficult to code and maintain

38 Other Smart Documents

39 Vertigo Managed Smart Document Wrapper Smart Documents In.NET Free, full source, and unsupported http://vertigosoftware.com/wrapper Great FAQ! Installs new.NET Smart Document project types in Visual Studio.NET 2003 VB.NET, C# Word, Excel Wraps the ISmartDocument interface in a way familiar to.NET developers Object oriented, “event” driven XML config file defines controls, event handlers Hides the low level “plumbing”

40 XML in Word & Excel 2003 Customer Defined XML Schema Mapping Work with data in a format that makes sense Visually relate XML elements to document parts Open or save just the data you need Apply XSLT to data input / output Submit directly to a web service Fully supports the W3C XSD standard But users do not have to know XML Word also supports full fidelity WordML Apps can produce or consume Word documents

41 Solution Benefits With XML Documents Text Document Fragment Image Text Document Fragment Image save 3 Searching & RepurposingContent Query Result 2 Business Process Efficiency Efficient capture Efficient capture Validated information Web service (loose coupled connection) Web service (loose coupled connection) + formatting 1 Improved Data Access + intelligent receipt 5 Document Assembly data formatting Context-specific assistance Context-specific assistance XML structure XML structure 4 Intelligent Applications XML

42 HTTP SOAP WSDL UDDI BizTalkSQL ERPCRM XML Electronic Forms Platform Gather information more flexibly and accurately Connect people, info and processes more effectively Develop & deploy information gathering solutions more easily

43 Our strategic tool for developing Office solutions Currently supports building document-centric solutions for Word and Excel 2003 VSTO makes Office development approachable to the profession developer Provides all the productivity of Visual Studio Provides all the power of the.NET Framework Leverages the skills of.NET developers VSTO solutions are secure and easy to deploy Based on.NET Code Access Security Online ClickOnce deployment model Visual Studio Tools for the Microsoft Office System

44 Visual Studio Tools for Office New Project Templates for VS.NET Extends.NET development to Office Application code is separate from document Flexible.NET code access security model Power of Office 2003 Code can run in Word and Excel Developer productivity of Visual Studio Write code in Visual Basic and Visual C#.NET Windows Forms presentation framework A “professional” development environment

45 Manipulating XML in Documents

46 VSTO Examples

47 What’s New In Visio 2003 Programmability Macro recorder Visio drawing control Managed code samples and tools for Visio 2003 SDK New events and automation

48 Macro Recorder Document programmers VBA macro generation Records user interaction with drawing surface Records user interaction with Visio’s ShapeSheet Application programmers Learn how the Visio API works Learn Visio concepts like glue

49 Visio Drawing Control ActiveX control for full Visio functionality Access to rich Visio API Single active document and window Multiple instances in a single application Integrated look and feel with host application Diagrams in context to application usage (form, web part, smart doc, web page) Programmatic control over drawing surface Mouse and keyboard events

50 Drawing Control Properties Document property Returns underlying Visio; Document object Window property Returns underlying Visio; Window object HostID property Returns or sets string that defines where to get registry settings SRC property Returns or sets the string for the file to load PageSizingBehavior property Indicates if the control should resize the page when the drawing is loaded into the control NegotiateMenus property Indicates if the control does menu merging with the host container NegotiateToolbars property Indicate if the control does toolbar merging with the host container

51 User Interface Customization Best practice: Complete UI customization Use your own context menus Use Visio events Respond to application events Also available: Visio application user interface “Activate” by setting BOTH NegotiateMenus and NegotiateToolbars properties to TRUE Do not menu merge with multiple simultaneous instances of the control OR in Internet Explorer Use IOleCommandTarget/DoCmd for C# and VB.NET (see MSDN for article and sample)

52 Drawing Control Containers Microsoft Office XP (including Access) Microsoft Office 2003 (including Access) InfoPath 1.0 and 1.1 through Solution Pane SharePoint Portal through Web Parts Internet Explorer 5.5 and later Visual Studio 6.0 (VB, C++) Visual Studio.NET 2003 (VB.NET, C#)

53 Drawing Control Licensing Required: Visio application install Minimal Install option for control only Typical Install for control and solutions No special licensing in addition to application license Full support for corporate deployments Will not initialize without Visio 2003 on the client machine

54 Managed COM Add-in Programming Easier development with Visio 2003 SDK Download SDK from MSDN to get managed code samples and tutorial Easier access to Visio Primary Interop Assemblies with Visio 2003 installation Reduce deployment requirements for third party applications Simplify PIA file installation and repairs

55 Visio 2003 SDK Available on MSDN for free download! Developer tools Event Monitor, Persistent Events, Solution Publishing Shape Studio for custom shape development VS 6.0 and VS.NET wizards for Visio solutions Samples Extensive application samples (VB, VB.NET, C#) and managed code tutorial Library of reusable functions, classes and sub-routines (VB, VB.NET, C#)

56 Visio Primary Interop Assemblies Primary Interop Assemblies (PIA) Visio 2003 type library Save As Web type library Visio 2003 drawing control type library Global Assembly Cache (GAC) support Installation and registration as part of product setup Requires.NET Framework 1.1 Visio 2003 SDK Visual Studio.NET Wizards

57 Some reasons to write code Capitalising on the.NET Framework Custom Data Connections External Automation External Automation Dynamic Task Panes Dynamic Task Panes Encryption Encryption Change Tracking and Logging Change Tracking and Logging Advanced Calculations and Validation Advanced Calculations and Validation

58 Form Template and Project Source Code (CS, VB) Project Definition (*PROJ) Form Template Files Visual Studio Project Assemblies (DLL and PDB) Template Definition (XSF) Default Data (XML) Schema (XSD) Views (XSLT) InfoPath Form Template (XSN) Publish / Preview.XML Form Data

59 Event Framework Open Edit Submit Close User C# VB.NET JScript VBScript Event Handlers OnLoad OnBeforeChange OnValidate OnAfterChange OnClick EventsOnSubmitRequest

60 Document Object Model sales XML DOM name items item item price units Form’s View

61 sales items item price sales items item Form Editing Events name item units Bubbling XML DOM OnAfterChange(DataDOMEvent e) Event Handler price

62 sales items item price Site Form Editing Events XML DOM OnAfterChange(DataDOMEvent e) Event Handler Bubbling hides source Use e.Site & e.Source Events fire twice! Use e.Operation Check for “Insert” Bubbling Source

63 Referencing Nodes w/ XPath sales XML DOM name items item item price units /ns:sales /ns:sales/ns:items /ns:sales/ns:items/ns:item

64 Referencing Nodes w/ XPath sales XML DOM name items item item price units /ns:sales Namespaces Every node has one Prefix = short hand DOM.selectSingleNode(“/ns:sales”); DOM & Node Methods selectSingleNode(Str)selectNodes(Str) Use “text” property

65 Object Model Overview XDocument DOM Windows XDocuments Application View Window DataObjects Errors TaskPanes CommandBars MailEnvelope Application lifecycle XDocument lifecycle User

66 Information Bridge Framework Web Service-based architecture (SOA) Centralized metadata/UI server Runtime for smart tag / XML event initiation Windows Forms and task pane support Metadata Finance ERP CRM Smart Clients Web Services

67 Information Bridge Architecture Client Server CRM Customer Information Invoices Orders SAP Legacy Application Aggregation Service Web Service Optional: Information Bridge Compliant Web Service Optional: Information Bridge Compliant Web Service Optional: Information Bridge Compliant Office Application (Word, Excel, Outlook) Attached Schema Smart Tag MetadataCache User Control Designer Visual Studio Development Only Web services U.I. (WinForm, XSLT) U.I. (SOAP) MetadataDesigner Metadata Service MetadataDatabase Information Bridge Runtime (Office add-in) Task Pane Manager Office Integration U.I. Rendering

68 Microsoft’s strategic tool for developing Office solutions New version supports building document-centric solutions for Word 2003, Excel 2003 and InfoPath 2003 Targeted at the professional developer Provides all the productivity of Visual Studio, and all the power of the.NET Framework Leverages the skills of.NET developers VSTO solutions are secure and easy to deploy Based on.NET Code Access Security No-touch/Online ClickOnce deployment model Visual Studio 2005 Tools for the Microsoft Office System

69 Visual Studio 2005 Tools for Office Visual Studio.NET 2005 with Projects for Word, Excel and InfoPath Language support for VB.NET and C# Full access to the.NET Framework, Web services, ADO.NET, integrated debugging CLR-based security model Major focus on developer productivity Integrated design-time experience Support for managed controls “View” controls Managed Document Actions Pane Schema-based programming model New data caching capabilities Data island accessible in a server environment Improved deployment model Online ClickOnce deployment model

70 Visual Studio Tools for Office 2.0

71 Document Data Island Using the Data Island Visual Studio Tools for Office provides the ability to cache data within documents Enables new server scenarios Pre-populates or extracts data, without having to program XML Excel or Word not instantiated Enables offline usage Uses cached lookup tables Requires no hidden sheets

72 Document Data Island Example of Caching Data [Cached()] CustomerDataSet customerDataSet; void ThisDocument_Initialize(…) { if (customerDataSet == null) { customerDataSet = new CustomerDataSet(); customerDataSet = new CustomerDataSet(); dataAdapter.Fill(customerDataSet); dataAdapter.Fill(customerDataSet); } list1.DataSource = customerDataSet; }

73 Document Data Island Requesting Data from a Server ASPX page Data Island User data Server-side code can pre-populate elements before sending to client

74 ASPX page Updated data Document Data Island Sending Data Back to a Server A VSTO 2005 enabled document is posted to a server, data is extracted, and sent to corporate data sources Updated Data Cache

75 Document Data Cache Using the ServerDocument class private void GetData() { string user = Request.ServerVariables("AUTH_USER"); ExpensesDataset dsExpenses = new ExpensesDataset(); ExpensesDataAdapter.Fill(dsExpenses, user); ServerDocument doc = new ServerDocument("expenses.xls"); ServerDocument("expenses.xls"); CachedDataItem cdi = doc.CachedDataManifest.Views ["ExpensesWorksheet"].CachedData["Expenses"]; cdi.SerializeDataInstance(dsExpenses);doc.Save();doc.Close();Response.Write(doc);}

76 Visual Studio Tools for Office 2.0 Server-Side Documents

77 Managed Document Actions task pane All the rich, UI features of Word and Excel Responsive UI - runs on local machine Data caching capabilities (data island) Document solution can be designed to work offline Support for calling Web Services through the.NET Framework and Visual Studio Managed Document Actions task pane Managed controls View controls Integrated design-time experience Schema-based programming model Complete access to the.NET Framework All the productivity of Visual Studio Online ClickOnce deployment model No-touch deployment model used for assembly resolution Document is linked to assembly; deployed to a share server Rich User Experience Responsive Web Services & Offline/Online support Developer Productivity Easy Change Management Ease of Deployment 2003 2005 Visual Studio 2005 Tools for Office

78 Resources http://msdn.microsoft.com/office/ The Definitive “Hello World” Managed Smart Documents Tutorial Microsoft Office 2003 Smart Documents SDK Research Services SDK How to: Install Office Primary Interop Assemblies Troubleshooting Office Error Messages http://vertigosoftware.com/wrapper Managed Smart Documents Wrapper

79 Additional Information Post Events Site All information on past events, slide decks etc http://www.microsoft.com/uk/msdn/postevents The UK MSDN Site & Flash Local news, events, webcasts http://www.microsoft.com/uk/msdn Register to receive the bi-weekly MSDN Flash by email http://www.microsoft.com/uk/msdn/flash.aspx Try Visual Studio http://www.microsoft.com/vstudio/tryit Take a look at the Express products http://msdn.microsoft.com/express GotDotNet and ASP.NET – lots of excellent resources http://www.gotdotnet.com http://www.asp.net

80 Morning Summary A Plethora of Techniques The Research Pane Smart Tags Smart Documents XML in Office Visual Studio Tools for Office VisioInfoPath The Information Bridge Framework Visual Studio 2005 & Office

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


Download ppt "Managed Code Development and Microsoft Office Mike Pelton Stephen Turner Developer & Platform Group Microsoft."

Similar presentations


Ads by Google