23
Scott Lock MVP, MCPD Managing Consultant Excella Consulting July 24 th , 2007

7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

Embed Size (px)

DESCRIPTION

Building office applications has never been better. You've heard all of the hype about Office 2007, Ribbons, etc. This session is based on what the majority of us are in today...Office 2003. Customizing and automating Excel 2003 is a great way to build dynamic workbooks that solve some cool problems. This presentation is an overview of what Visual Studio Tools for office is about and how it applies to Excel 2003 and Office 2003.

Citation preview

Page 1: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

Scott LockMVP, MCPDManaging ConsultantExcella ConsultingJuly 24th, 2007

Page 2: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

Special Thanks

Frank LaVigne for developing the original slide deck and inspiration for

demos

Page 3: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

What exactly is VSTO?Pros & Cons of VSTO developmentThree Patterns of VSTO ProjectsAdvantages of VSTO Over VBA

Integration With Visual StudioXML Mapping in ExcelFuture of VSTO

Page 4: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

VSTO: Visual Studio Tools for OfficeProvides design time integration with

Microsoft Office DocumentsAllows .NET Code to Interoperate

with Microsoft Office products It’s not your father’s VBA

Page 5: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003
Page 6: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003
Page 7: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

Demo

Automation client

Page 8: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

VSTO code is Managed CodeCode is stored in a DLL file

And not in the documentMore security optionsCan leverage existing .NET Libraries

XML, Web Services, etcAdditional Features

Caching

Page 9: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003
Page 10: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

Creating a VSTO Customization Project

Page 11: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

Deployment

Deployment model based on ClickOnce *Not “really” ClickOnce in VSTO 2005

Uses Manifests to version and locate assemblies Deployment Manifest – points to the most

current version of the application Application Manifest – contains info on

where the customization assembly is and host item classes to create

Page 12: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

Deployment

How it works…

Workbook.xlsWorkbook.xls

Workbook.application(Embedded and File)

Workbook.application(Embedded and File)

Workbook.dll.manifestWorkbook.dll

Workbook.dll.manifestWorkbook.dll

C:\deploy\workbook_1.0.0.0

Workbook.dll.manifestWorkbook.dll

Workbook.dll.manifestWorkbook.dll

C:\deploy\workbook_1.0.0.1

Workbook.dll.manifestWorkbook.dll

Workbook.dll.manifestWorkbook.dll

C:\deploy\workbook_1.0.0.2

Page 13: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

Security

Code Access Security is used to keep “evil” VSTO assemblies from executing

“Not Trusted” by default You must explicitly add the assembly

in order to execute VSTO Add scripts for automated deployments Use intellimirror for network deployments

to support disconnected machines Visual Studio automatically adds the

CAS entry each time you run in debug

Page 14: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

Data Caching

XML Data Island used to cache data with workbook itself

Rich object model available to access data ServerDocument.CachedData

Full control over cache lifecycle or simple attribute based caching

Any object that can be serialized can be cached Datasets Strings Arrays

Page 15: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

Publishing Attaching/Detaching customizationsCaching Data

Page 16: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

XML Support

XML is supported using XML Maps Maps are schemas associated to a

workbook Workbooks can contain multiple maps Elements and attributes are visually

mapped to ranges in worksheetXML Data can be imported/exportedSpecial object XMLList used for

repeating elements

Page 17: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

Excel’s Built-In XML Mapping Capabilities

Excel XML ToolkitProgrammatically Accessing XML

Page 18: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

Excel Object Model

Application – Highest level Workbooks

▪ Worksheets▪ Ranges

Cells Access to these objects is through Interop

wrapper classes Classes are extended by VSTO

Ex. Microsoft.Office.Tools.Excel.Worksheet VSTO adds two additional range host controls

NamedRange, XMLMappedRange

Page 19: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

Microsoft.Office.Tools.Excel vs. Microsoft Office.Interop.Excel Microsoft.Office.Tools extends native

objects Data-binding Richer event models

Extended objects added at design time are automatically created as host items and host controls Ex. Interop.Excel.Range does not have events,

Tools.Excel.Range adds events. Host items are not created at run time.

Are only Excel Native objects with no added features

Native object access via the innerobject property

Page 20: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

Demo

Calling a WebserviceUsing Excel Objects

Page 21: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

VSTO 2005 SE (Second Edition) released. Includes support for Office 2007 as well

as Add-In templates for VisioRibbonX API for developing custom

Office 2007 ribbons.

VSTO Provides a Smart Client complement to MOSS Development.

Page 22: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

Books Visual Studio Tools for Office

by Eric Carter & Eric Lippert VSTO for Mere Mortals

by Kathleen McGrath & Paul StubbsWebsites

Office Zealothttp://www.officezealot.com

MSDN Office Developer Centerhttp://msdn2.microsoft.com/en-us/office/default.aspx

VSTO Developer Portalhttp://msdn2.microsoft.com/en-us/office/aa905533.aspx

Page 23: 7/24/2007 Caparea.net Presentation - Visual Studio Tools for Office - Automation and Customizing Excel 2003

Any questions?