vsto 3 snug

34
VSTO 3.0 Programming and VSTO 3.0 Programming and Deploying an Excel Add- Deploying an Excel Add- In In Miguel Santos Miguel Santos Sr. Software Developer Sr. Software Developer Nielsen Nielsen Email: [email protected] Email: [email protected]

Upload: guest5b8655

Post on 07-Nov-2014

1.797 views

Category:

Technology


2 download

DESCRIPTION

This ia a presentation that I did at my local user group. It provides the basics to get you started in how to program and deploy an Excel Add-In using C#

TRANSCRIPT

Page 1: Vsto 3 Snug

VSTO 3.0 Programming and VSTO 3.0 Programming and Deploying an Excel Add-InDeploying an Excel Add-In

Miguel SantosMiguel Santos Sr. Software DeveloperSr. Software Developer NielsenNielsen Email: [email protected]: [email protected]

Page 2: Vsto 3 Snug

AgendaAgenda

Define VSTO and Add-InDefine VSTO and Add-In Create, Build and Deploy Excel Add-In on Create, Build and Deploy Excel Add-In on

Visual Studio Tools for Microsoft Office Visual Studio Tools for Microsoft Office System (VSTO) 3.0 / Visual Studio .NET System (VSTO) 3.0 / Visual Studio .NET 2008 SP12008 SP1

Deployment & SecurityDeployment & Security Troubleshooting Deployment Troubleshooting Deployment DemosDemos

Page 3: Vsto 3 Snug

AssumptionsAssumptions

Excel 2007Excel 2007 VS 2008 setup projectVS 2008 setup project Excel automationExcel automation

Page 4: Vsto 3 Snug

VSTO DefinitionVSTO Definition

Microsoft’s strategic tool for developing Microsoft’s strategic tool for developing Office solutions.Office solutions.

It helps building applications that run on It helps building applications that run on MS Office.MS Office.

VSTO solutions are secure and easy to VSTO solutions are secure and easy to deploydeploy Based on .NET Code Access SecurityBased on .NET Code Access Security Offers ClickOnce deployment model as one of the Offers ClickOnce deployment model as one of the

development optionsdevelopment options

Page 5: Vsto 3 Snug

VSTO Definition (cont)VSTO Definition (cont)

VSTO makes Office development available VSTO makes Office development available to .NET developersto .NET developers Provides all the productivity of Visual Studio IDEProvides all the productivity of Visual Studio IDE Provides all the power of the .NET Framework.Provides all the power of the .NET Framework. Leverages the skills of .NET developersLeverages the skills of .NET developers

Page 6: Vsto 3 Snug

VSTO HistoryVSTO History

Before VSTO (VBA and COM automation Before VSTO (VBA and COM automation using C++ and VB6)using C++ and VB6)

VSTO 2003. Target: Office 2003VSTO 2003. Target: Office 2003 VSTO 2005. Target: Office 2003(Outlook)VSTO 2005. Target: Office 2003(Outlook) VSTO 2005 Second Edition. Target: Office VSTO 2005 Second Edition. Target: Office

2003/20072003/2007

Page 7: Vsto 3 Snug

VSTO History (cont)VSTO History (cont)

VSTO 3.0. Target: Office 2003/2007. VSTO 3.0. Target: Office 2003/2007. Integrated to VS2008.Integrated to VS2008.

VSTO 2010 (v4 – April 2010). Target: VSTO 2010 (v4 – April 2010). Target: Office 2003/2007/2010Office 2003/2007/2010

Page 8: Vsto 3 Snug

VSTO 3 VSTO 3 ProgrammingProgramming New New featuresfeatures

Visual designer for RibbonsVisual designer for Ribbons Excel, Word 2007 document support.Excel, Word 2007 document support. Task panesTask panes Smart tagsSmart tags Rich user interface controlsRich user interface controls

Page 9: Vsto 3 Snug

VSTO 3 Deployment New features VSTO 3 Deployment New features

NET Framework 3.5/SP1 client profileNET Framework 3.5/SP1 client profile Click OnceClick Once Office 2007 System as prerequisitesOffice 2007 System as prerequisites VSTO Power ToolsVSTO Power Tools

Page 10: Vsto 3 Snug

VSTO Add-InVSTO Add-In

Application-level solution resides in the Application-level solution resides in the program itself.program itself.

Class-library project associated with a Class-library project associated with a supported Office application supported Office application

Library assembly runs as an add-in within Library assembly runs as an add-in within the host application's domain the host application's domain

Page 11: Vsto 3 Snug

VSTO Add-In (cont)VSTO Add-In (cont)

It supports Office 2003: Excel, Word, It supports Office 2003: Excel, Word, Outlook, Powerpoint, Project, VisioOutlook, Powerpoint, Project, Visio

It supports Office 2007: Excel, Word, It supports Office 2007: Excel, Word, Outlook, InfoPath, Powerpoint, Project, Outlook, InfoPath, Powerpoint, Project, VisioVisio

Page 12: Vsto 3 Snug

Excel Add-InExcel Add-In

Application add-in resides in Excel in an Application add-in resides in Excel in an AppDomain.AppDomain.

VSTO creates the class library project.VSTO creates the class library project. It defines main object: ThisAddIn.It defines main object: ThisAddIn. It creates two methods: Startup, Shutdown.It creates two methods: Startup, Shutdown. It adds required Excel/VSTO references.It adds required Excel/VSTO references.

Page 13: Vsto 3 Snug

Excel Add-InExcel Add-In

Demo Hello WorldDemo Hello World

Page 14: Vsto 3 Snug

Excel Object ModelExcel Object Model

Excel PIA are managed assemblies that Excel PIA are managed assemblies that wrap the Office COM-based interfaces for wrap the Office COM-based interfaces for use within .NET developmentuse within .NET development

Key objects are:Key objects are:• ApplicationApplication

• WorkbookWorkbook

• WorksheetWorksheet

• RangeRange

Page 15: Vsto 3 Snug

ApplicationApplication

It represents the Excel application itself.It represents the Excel application itself. Properties: ActiveWorkbook, ActiveSheet, Properties: ActiveWorkbook, ActiveSheet,

ActiveCell, WorkbooksActiveCell, Workbooks Methods: Quit, Run, SaveMethods: Quit, Run, Save Code: Globals.ThisAddIn.ApplicationCode: Globals.ThisAddIn.Application

Page 16: Vsto 3 Snug

WorkbookWorkbook

It represents an Excel workbook.It represents an Excel workbook. Properties: ActiveSheet, Name, Sheets, Properties: ActiveSheet, Name, Sheets,

Worksheets, VisibleWorksheets, Visible Methods: SaveAsMethods: SaveAs Events: WindowActivate, BeforeCloseEvents: WindowActivate, BeforeClose Code: Application.ActiveWorkBookCode: Application.ActiveWorkBook

Page 17: Vsto 3 Snug

WorksheetWorksheet

It represents an Excel worksheet.It represents an Excel worksheet. Properties: Cells, ActiveCell, Name, VisibleProperties: Cells, ActiveCell, Name, Visible Methods: Copy, Select, SaveAsMethods: Copy, Select, SaveAs Events: SelectionChangeEvents: SelectionChange Code: Code:

(Excel.Worksheet)(Excel.Worksheet)Application.ActiveSheetApplication.ActiveSheet

Page 18: Vsto 3 Snug

RangeRange

It represents an Excel range.It represents an Excel range. Properties: Borders, Cells, Name, Value2Properties: Borders, Cells, Name, Value2 Methods: Activate, Clear, Copy, SelectMethods: Activate, Clear, Copy, Select Code: Application.ActiveCell, Code: Application.ActiveCell,

Application.CellsApplication.Cells

Page 19: Vsto 3 Snug

RibbonRibbon

New way to implement menu items in Office New way to implement menu items in Office (Replaces menu and toolbar)(Replaces menu and toolbar)

It contains tabs that hold all required It contains tabs that hold all required commands/window controls.commands/window controls.

Add ribbon to add-in project. Add ribbon to add-in project. Options: Visual designer or XmlOptions: Visual designer or Xml Available windows controls are button, Available windows controls are button,

combo box, checkbox, etc.combo box, checkbox, etc.

Page 20: Vsto 3 Snug

Excel Add-InExcel Add-In

Demo Common TasksDemo Common Tasks

Page 21: Vsto 3 Snug

Deployment OverviewDeployment Overview

Options:Options: ClickOnceClickOnce MSI/Setup.exeMSI/Setup.exe Document Deployment with WSS/MOSSDocument Deployment with WSS/MOSS

Page 22: Vsto 3 Snug

Deployment StepsDeployment Steps

Check/Install prerequisitesCheck/Install prerequisites Deploy Add-In (HKCU)Deploy Add-In (HKCU) Update registry andUpdate registry and Set up security (Full trust)Set up security (Full trust)

Page 23: Vsto 3 Snug

Deployment Windows InstallerDeployment Windows Installer

Custom branding installationCustom branding installation Can deploy additional Can deploy additional

assemblies/components and registry assemblies/components and registry settings.settings.

Can allow custom configuration via user Can allow custom configuration via user interactioninteraction

More developer effortMore developer effort No automatic updatesNo automatic updates

Page 24: Vsto 3 Snug

Windows Installer PrerequisitesWindows Installer Prerequisites

Windows Installer 3.1Windows Installer 3.1 NET Framework 3.5/SP1NET Framework 3.5/SP1 VSTO Runtime SP1VSTO Runtime SP1 Office 2007 PIAOffice 2007 PIA

Page 25: Vsto 3 Snug

Create Windows InstallerCreate Windows Installer

Prepare development PC. (VS 2008 Prepare development PC. (VS 2008 SP1, .NET 3.5SP1)SP1, .NET 3.5SP1)

Create Add-In and basic installer project.Create Add-In and basic installer project. Add Add-in project as project output Add Add-in project as project output

group.group. Add deployment and application manifests.Add deployment and application manifests.X Configure prerequisitesConfigure prerequisitesX Add registry settingsAdd registry settings

Page 26: Vsto 3 Snug

Create Windows Installer (cont)Create Windows Installer (cont)

Configure launch conditionsConfigure launch conditions VSTO run timeVSTO run time Office Shared PIAOffice Shared PIA Excel PIAExcel PIA

Configure a single-user installationConfigure a single-user installation Build MSI/Setup.exe.Build MSI/Setup.exe.

Page 27: Vsto 3 Snug

Create Windows Installer Create Windows Installer (Optional)(Optional)

Bootstrap component check setup. (Office Bootstrap component check setup. (Office 2003 PIA)2003 PIA)

Language pack.Language pack. More assembly/componentsMore assembly/components Click once cache deploymentClick once cache deployment All users deployment – See Misha’s blogAll users deployment – See Misha’s blog Vista deployment- check UAC compliant Vista deployment- check UAC compliant

boxbox

Page 28: Vsto 3 Snug

Deployment Windows InstallerDeployment Windows Installer

Demo Excel Add-In msi.Demo Excel Add-In msi.

Page 29: Vsto 3 Snug

TroubleshootingTroubleshooting

VSTO TroubleshooterVSTO Troubleshooter Windows Event log contains Deployment Windows Event log contains Deployment

and installation error messagesand installation error messages

Page 30: Vsto 3 Snug

SummarySummary

VSTO is a set of Visual Studio project VSTO is a set of Visual Studio project templates and runtimes for building add-ins templates and runtimes for building add-ins for Microsoft Office solutions.for Microsoft Office solutions.

Introduction to Excel's main objects and Introduction to Excel's main objects and how to perform common tasks using VSTOhow to perform common tasks using VSTO

Deployment using Windows Installer has Deployment using Windows Installer has been simplified but it is still a complex task.been simplified but it is still a complex task.

Page 31: Vsto 3 Snug

ResourcesResources

MSDNMSDN Excel Object Model OverviewExcel Object Model Overview Deploying Office SolutionsDeploying Office Solutions Security in Office SolutionsSecurity in Office Solutions Deploying a VSTO 3.0 Solution Using Windows Deploying a VSTO 3.0 Solution Using Windows

Installer Installer • (Part 1 of 2)(Part 1 of 2)

• (Part 2 of 2)(Part 2 of 2)

Page 32: Vsto 3 Snug

Resources (Cont)Resources (Cont)

BlogsBlogs VSTO TeamVSTO Team Andrew CoatesAndrew Coates Andrew WhitechappelAndrew Whitechappel Misha ShneersonMisha Shneerson

• Deploying your VSTO 2008 Add-In to All Users Deploying your VSTO 2008 Add-In to All Users Part IPart I, , Part IIPart II, , Part IIIPart III

Page 33: Vsto 3 Snug

VSTO 2010 improvementsVSTO 2010 improvements

C# support for optional parameters.C# support for optional parameters. Click once:Click once:

Setup can target multiple Office application.Setup can target multiple Office application. Post deployment custom actions. (e.g. moving files Post deployment custom actions. (e.g. moving files

to user directories, deleting files during uninstallto user directories, deleting files during uninstall , , registryregistry))

No-PIA installs. (No-PIA installs. (PIA PIA is part of the .NET is part of the .NET framework)framework)

Page 34: Vsto 3 Snug

Thank you Thank you

Q & AQ & A