The Microsoft Developer Tools Roadmap 2004 – 2005 lays out a good description of Microsoft Visual Studio Tools for the Microsoft Office System, Version 2.0. It describes how the new version separates data from view, so that you can program against the data in a document without having to code against the Microsoft Office Excel and Microsoft Office Word object models. But what is the view, exactly?
In the most generic sense, the view is the Microsoft Office Word or Microsoft Office Excel document. But view is also used more specifically to mean a container object that can contain controls. (It also contains a data cache, but more about that in a later post.)
There are new controls in Visual Studio Tools for Office, Version 2.0 that are called view controls. View controls are intrinsic Word or Excel objects that have been enhanced by the addition of events and data binding capability. View controls can be added to a Word or Excel document in much the same way that you would add Windows Forms controls to a Windows Form.
An example of a view control for Excel is the named range object, which is an Excel cell range that you identify with a name. Once you add a named range to a worksheet, Visual Studio Tools for Office, Version 2.0 creates a first class object that you can program against directly without having to traverse the Excel object model. For example, instead of writing Application.Worksheets(“Sheet1”).Cells(2, 2).Value2 = salesTotal, you could simply write TotalNamedRange.Value2 = salesTotal.
An example of a view control for Word is the bookmark, which you can program against in a similar way.
In other words, a view is a container (Word document or Excel worksheet) for view controls (NamedRange, Bookmark, and so on) that exposes events and can be bound to data.
- View – container
- View controls – contained inside view
- Excel: view = worksheet, view control = range
- Word: view = document, view control = bookmark
— Harry Miller
This posting is provided “AS IS” with no warranties, and confers no rights.