Visual Studio Tools für Office 2007
Next Generation Applications for Office - Teil 2
Marcel Gnoth, Avanade Deutschland GmbH
CS3, VB7, OF2, PA12
2
Marcel Gnoth, www.gnoth.net , © 2006
Zur Person• Dipl. Inf. Marcel Gnoth, MCSD
• Senior Consultant, Avanade Deutschland GmbH• Office Business Application Group & Business Intelligence• [email protected] , www.gnoth.net (Code+Folien)
• Autor • dotnetpro, dotnet-magazin, Developerworld, MSDN
• Sprecher • BASTA!, TechTalk, SQL Server Days, NRW06
• Themen• Verteilte nachrichtenbasierte Informationssysteme
• MS Message Queueing, SQL Server Service Broker• Office System 2003 / 2007 Integration• BI, ETL, Reporting• VB6, COM, SQL Server, .Net
3
Marcel Gnoth, www.gnoth.net , © 2006
Über Avanade• Gegründet als Joint Venture von
Accenture und Microsoft im April 2000 • Focus auf MS Technologien• Anbindung an SAP und andere Systeme
• Ein führender Technologie-Integrator • mit über 4.000 Mitarbeitern in 21 Ländern• Unternehmenslösungen auf Basis von
Microsoft-Technologien• über 3.000 Projekte bei rund 1.900 Kunden
weltweit
5
Marcel Gnoth, www.gnoth.net , © 2006
Globale Präsenz• Avanade wächst stetig und zählt im Februar 2006 mehr als 4.000
Mitarbeiter in 21 Ländern, sowie über 3.000 Projekte bei rund 1.900 Kunden.
Avanade Americas• Seattle• San Francisco• Chicago • Dallas• Boston • New York• Toronto• St. Louis• Nashville• Kansas City• Cincinnati
Avanade Europe•Almere•Barcelona•Brussels•Copenhagen•Edinburgh•Helsinki•Kronberg•London•Málaga•Madrid•Milan•Oslo•Paris•Rome•Stockholm •Zurich
Avanade Australia• Sydney• Melbourne• Brisbane• Canberra
Avanade Asia• Singapore• Kuala Lumpur• Bangkok• Tokyo
Avanade India• Mumbai• Bangalore• Hyderabad
Avanade Philippines• Manila
7
Marcel Gnoth, www.gnoth.net , © 2006
Agenda – Was gibt es neues• Überblick• Microsoft Office Open XML Formats
(Office XML Formats)• Word, Excel, PowerPoint• Vortrag von Jens Häupel, OFF 4
• Content Controls und XML – Mapping • Taskpanes auf Applikation Ebene• Ribbon - User Interface
• Word, Excel, PowerPoint• Vortrag von Jens Häupel, OFF
8
Marcel Gnoth, www.gnoth.net , © 2006
VSTO – Zwischenrelease• Office 2007 + Visual Studio 2005
• VSTO 2005 Cypress • Visual Studio 2005 Tools for Office
Second Edition (VSTO 2005 SE)• http://msdn.microsoft.com/office/tool/vsto/
2005SE/default.aspx
• Beta
• Office 2007 + VSTO V3 • Nächste Visual Studio Version (Orcas)
Task Panes & Actions Panes
Applikationsbezogenes UI
10
Marcel Gnoth, www.gnoth.net , © 2006
Taskpanes• Windows Froms Userinterface• Integriert in Office• Office 2003:
• Auf Dokumentebene• Dokument Aktionen
• Office 2007• Auch auf Applikationsebene• Aufgabenbereich
11
Marcel Gnoth, www.gnoth.net , © 2006
Dokument Aktionen• Taskpane ist mit dem geladenen
Dokument verbunden• Auch Actions Pane genannt• ISmartDocument Technologie• Im Dokument ist ein Verweis Assembly
gespeichert• Runtime Storage Control• Application Manifest
• Assembly wird geladen
12
Marcel Gnoth, www.gnoth.net , © 2006
Custom TaskPanes• Neues ICustomTaskPaneConsumer
Interface• Neues Projekt: AddIn
13
Marcel Gnoth, www.gnoth.net , © 2006
Custom TaskPanes• Dll Projekt• UserControl hinzufügen• Excel startet beim Debuggen• Neue Taskpane mit UserControl
erstellenPrivate Sub ThisApplication_Startup(…) Handles Me.Startup Dim ctp As Microsoft.Office.Tools.CustomTaskPane = Nothing ctp = CustomTaskPanes.Add(New ucExcel(), "Moin") ctp.Visible = TrueEnd Sub
14
Marcel Gnoth, www.gnoth.net , © 2006
Custom TaskPanes• Zugriff auf Excel Objekte
• Globals.ThisApplicationDim s As Excel.Worksheet = _ CType(Globals.ThisApplication.ActiveSheet, _ Excel.Worksheet)s.Cells(3, 6) = "Hallo, Moin: " & Now
15
Marcel Gnoth, www.gnoth.net , © 2006
Stacking und Order• Mehrere TaskPanes (AddIn) erscheinen
nebeneinander• Stellen je ein UserControl dar
• ActionsPane (Doc) erscheint neben TaskPane (AddIn)• ActionsPane (Doc) erscheint nur einmal und
stellt mehrere UserControls dar• Stacking Order und Layout
Demo
ActionsPane
Content Controls & XML Mapping
Trennung von XML – Daten und DokumentContent Controls
XML Mapping
18
Marcel Gnoth, www.gnoth.net , © 2006
Content Controls• Neu in Word 2007• Vordefinierte Platzhalter, die der Anwender
ausfüllen soll• Verschiedene Typen, wie Textbox, drop-down
oder Calender• Können XML Daten zugeordnet werden• Können gegen löschen gesperrt werden• Trennung von Dokument und Formulardaten
19
Marcel Gnoth, www.gnoth.net , © 2006
Content Control• Bei MausOver erscheint es • Ber MouseExit verschwindet es
20
Marcel Gnoth, www.gnoth.net , © 2006
Content Controls• Hinzufügen durch UI (Tab Entwickler
Tools)
21
Marcel Gnoth, www.gnoth.net , © 2006
Neue Klassen in Office• Listen
• ContentControls• Document• Range• Selection objects
• ContentControlEntries• wdContentControlComboBox• wdContentControlDropDownList
22
Marcel Gnoth, www.gnoth.net , © 2006
Neue Klassen in Office• ContentControl
• wdContentControlDate • wdContentControlText • wdContentControlRichText• wdContentControlBlockPicture• wdContentControlComboBox• wdContentControlDropDownList• wdContentControlBuildingBlockGallery
• ContentControlEntry• XMLMapping
23
Marcel Gnoth, www.gnoth.net , © 2006
Content Control – Code• Titel wird dem Anwender als Hilfe
angezeigt• Über den Titel oder den Index kann ein
Content-Control referenziert werdenDim oCC As Word.ContentControlSet oCC = Application.Selection.ContentControls.Add _
(wdContentControlText)oCC.Title = "MyTitle"oCC.SetPlaceholderText ,,"Type text here"oCC.LockContentControl = TrueoCC.LockContents = True
ActiveDocument.ContentControls.Item("MyTitle").DeleteActiveDocument.ContentControls.Item(1).Delete
Dim oCC As Word.ContentControlSet oCC = Application.Selection.ContentControls.Add _
(wdContentControlText)oCC.Title = "MyTitle"oCC.SetPlaceholderText ,,"Type text here"oCC.LockContentControl = TrueoCC.LockContents = True
ActiveDocument.ContentControls.Item("MyTitle").DeleteActiveDocument.ContentControls.Item(1).Delete
24
Marcel Gnoth, www.gnoth.net , © 2006
XML Mapping• Trennung der XML-Daten von
Dokument- Formatierung und Layout. • Data / View
• Verbindet Dokument mit einer XML Datei
• Office XML Format speichert Custom XML Daten in Document Parts • Dokumente können mehrere Custom Data
Stores enthalten
25
Marcel Gnoth, www.gnoth.net , © 2006
XML Mapping• XML-Mapping zwischen Content Controls
und Custom Data Store• Über XPath Definitionen
• Dokument kann gefüllt werden über eine XML Datei
• Über das Objekt Modell können Custom DataStores hinzugefügt und zugeordnet werden
26
Marcel Gnoth, www.gnoth.net , © 2006
Weitere neue Klassen in Office 2007
• CustomXMLNamespaceManager• Zuordnung zwischen Namespaces und
Prefixes
• CustomXMLSchemaCollection• Schemata für Custom XML Parts
• CustomXMLSchema• Ein Schema
• CustomXMLParts• Collection der Custom XML Parts• Auch DataStore des Dokumentes
27
Marcel Gnoth, www.gnoth.net , © 2006
Weitere neue Klassen in Office 2007• CustomXMLPart
• Ein Custom XML Part des DataStore• CustomXMLNodes
• Menge der CustomXMLNode-Objekte des aktuellen Dokumentes
• CustomXMLNode• Neue msoXMLDataNodeType Enumeration
• msoXMLNodeAttribute • msoXMLNodeCData • msoXMLNodeComment • msoXMLNodeDocument • msoXMLNodeElement • msoXMLNodeProcessingInstruction • msoXMLNodeText
28
Marcel Gnoth, www.gnoth.net , © 2006
Custom XML Part hinzufügen• Part hinzufügen• XML aus Datei laden
• Jedes Part wird in separater Datei abgelegt• Ordern: /customXml/item1.xml
Dim oCustomXMLPart As Office.CustomXMLPartDim strXMLPartName As StringstrXMLPartName = "c:\myDataStoreFiles\myXMLDataStore.xml"
' First, add a new custom XML part to the documentSet oCustomXMLPart = ActiveDocument.CustomXMLParts.Add
' Second, load the XML file into the custom XML partCall oCustomXMLPart.Load(strXMLPartName)
Dim oCustomXMLPart As Office.CustomXMLPartDim strXMLPartName As StringstrXMLPartName = "c:\myDataStoreFiles\myXMLDataStore.xml"
' First, add a new custom XML part to the documentSet oCustomXMLPart = ActiveDocument.CustomXMLParts.Add
' Second, load the XML file into the custom XML partCall oCustomXMLPart.Load(strXMLPartName)
29
Marcel Gnoth, www.gnoth.net , © 2006
XML mit Content Controls verbinden
• String mit XPath dem ContentControl Object zuweisen• SetMapping Methode
' First, create the XPathDim strXPath As StringstrXPath = "/s:book/s:AuthorFirstName„
' Next, create an instance of a content control to work withDim oContentControl As Word.ContentControlSet oContentControl = Application.Selection.ContentControls.Add _ (wdContentcontrolComboBox)' Last, map the data using the XPathoContentControl.XMLMapping.SetMapping strXPath
' First, create the XPathDim strXPath As StringstrXPath = "/s:book/s:AuthorFirstName„
' Next, create an instance of a content control to work withDim oContentControl As Word.ContentControlSet oContentControl = Application.Selection.ContentControls.Add _ (wdContentcontrolComboBox)' Last, map the data using the XPathoContentControl.XMLMapping.SetMapping strXPath
Demo
Content Controls
Open XML File Format
Office Dokumente als Zip-Archive
32
Marcel Gnoth, www.gnoth.net , © 2006
Office Open XML Format• Open Packaging Conventions • System.IO.Packaging
33
Marcel Gnoth, www.gnoth.net , © 2006
System.IO.Packaging• WinFX / .Net 3• Referenz auf
• C:\WINDOWS\assembly\GAC_MSIL\WindowsBase\3.0.51116.0__31bf3856ad364e35\WindowsBase.dll
Imports System.IO.PackagingPrivate wdPackage As PackagePrivate corePropertiesPart As PackagePart
wdPackage = Package.Open( _ docName, FileMode.Open, FileAccess.ReadWrite)corePropertiesPart = wdPackage.GetPart(corePropertiesUri)
Imports System.IO.PackagingPrivate wdPackage As PackagePrivate corePropertiesPart As PackagePart
wdPackage = Package.Open( _ docName, FileMode.Open, FileAccess.ReadWrite)corePropertiesPart = wdPackage.GetPart(corePropertiesUri)
34
Marcel Gnoth, www.gnoth.net , © 2006
Ändern / Erstellen der Dokumente• Zugriff nur auf das XML in den Zip-
Dokumenten• Kein Office erforderlich• Serververarbeitung
Demo
Eigenschaften Eines Dokumentes ändern
36
Marcel Gnoth, www.gnoth.net , © 2006
Alles wird gut
Uff...Uff...
37
Marcel Gnoth, www.gnoth.net , © 2006
Dokument Inspektoren• Nach Fertigstellung des Dokumentes
• Prüfen auf persönliche Infos• Überarbeitet Texte und Kommentare• anderes
• Eigene entwickeln• Zum Beispiel Prüfen auf Worte und
Redewendungen, die nicht verwendet werden sollen
• http://msdn2.microsoft.com/en-us/library/aa338203.aspx
38
Marcel Gnoth, www.gnoth.net , © 2006
Links• What's New for Developers in Word 2007
• http://msdn2.microsoft.com/en-us/library/ms406055.aspx
• Microsoft Office Compatibility Pack for Word, Excel, and PowerPoint 2007 File Formats • http://www.microsoft.com/office/preview/beta/converter.mspx
• Custom Task Panes: Doc-Level and App-Level • http://blogs.msdn.com/andreww/archive/
2006/07/31/684595.aspx • What's New for Developers in Word 2007
• http://msdn2.microsoft.com/en-us/library/ms406055.aspx • Introducing the Microsoft Office (2007) Open XML File Formats
• http://msdn2.microsoft.com/en-us/library/aa338205.aspx • http://msdn2.microsoft.com/en-us/library/ms771890.aspx
• Creating Word 2007 Templates Programmatically • http://msdn2.microsoft.com/en-us/library/ms406053.aspx