Last night I attended a Visual Studio 2005 Tools for 2007 Office System event presented by Mike Hernandez and organised by the Dublin Area MTUG (Microsoft Technology User Group) in the quaint surroundings of Buswell's Hotel. Office 2007 is now a true platform with good infrastructure to build solutions on to. VSTO, a free add-on to VS, is effectively a bridge between Office and Visual Studio.
Developer Benefits:
- Utilize key 2007 Office System UI features using VSTO and Office
- RAD Design Expereince for building Office based apps
- Build OBAs that leverage enterprise resources. The result being a more streamlined approach to tasks and processes. Mike advised how Elite Model Agency in New York created a new Outlook Add-In which allows user to graphical choose and select a model. Once selected, the models schedule appears in Outlook thus streamlining the process.
DEMO's:
- Making a VSTO Project: EXCEL Add-In
Visual Studio > Create New Project > Office 2007/2003
Select Excel Add-In - this will build the infrastructure
In Excel 2003 and previous editions, by selecting help, a task pane would appear in the right hand side of the screen. Custom task panes can now be created in VSTO.
Create custom task pane > Add New Item > User Control > WinForm Designer appears
Place control i.e. NAME
Now go to Code VB via tab and insert snippet (Code previously saved)
Save > Build > Run Solution
Excel Opens and custom task pane opens
Excel Options > Add-Ins > Enable/Disable Add-Ins
2. Creating an OUTLOOK Add-In
In OUTLOOK, in the task list view, the user can create custom fields. If however you open a specific task, there is no user designed field. Office 2007 uses Applet Form Regions and VSTO uses a Wizard.
Go to Trust Centre > Add-Ins and delete previous Add-Ins
Visual Studio: File > New > Project > Outlook Add-In
Right click desired solution > Outlook Add-In > Form Region
Double click the form region and insert snippet
Save > Build > Run Solution
Open Outlook and user designed field appears in the specific task window
3. Created a Document Level Solution
Visual Studio: Create Excel Workbook Solution - Excel now appears inside VS
Add New Data Source > Database and choose either Oracle/SQL/Access
For the demo, Mike choose SQL
Click Test Connection
If successful, Retrieve Database Information
On left hand side, you can now choose specific Tables, Fields and Stored Procedures
Drag and drop onto Excel
Save > Build
Data Integrity is crucial so check in SQL to ensure correct data has been extracted into Excel
Insert button onto Excel and in code tab, insert snippet.
Mike created a NEXT and PREVIOUS buttons so that by pressing either, the user can see for example previous Customer ID or the next Customer ID.
These buttons can now be removed and a pane can be created.
Choose Binding Navigator in WinForm tab
Double Click > code tab will open and insert snippet
Set bindingsource=customerbindingsource
Show Custom Actions Pane
Save > Build > Run
The result is that you have now created a custom task pane which allows you to scroll through various customer data via:
< 1 of 90 >
Add Ribbon in Visual Designer in VS:
From Right-hand side, you can drag and drop data sources i.e. Fields or Tables onto EXCEL. Farewell to Pivot Tables! Also if you create a chart and place on a new sheet, as you scroll through the customer orders, it automatically updates :).
Deployment
User must have EXCEL, the DLL and vsto run-time on the machine. The new version of VSTO, enables the user to click one and downloads dll with data
The dll is seperate from Excel. Email the spreadsheet. Once opened it fires up. If you need a new applet in the solution, change the dll where the code is saved and insert new snippet. When spreadsheet is opened again, it will check for changes on the network.
The fact that the code doesnt live with the spreadsheet is important both from a security and maintenance perspective.
VSTO Definitions:
- Doc Level - specific to one doc/spreadsheet - useful in banking - security
- Application Level - custom task pane which applies to any document in the host
Resources:
Download VSTO 2005 SE
Click here for all you need to know on VSTO
Creating Custom Task Panes
Binding Data to User Controls in Excel
Download C# VS2005 Code Snippets