Using the Office Object Model

The Office 2003 object library includes a set of objects for working with documents stored in document workspace sites and document libraries. You can use those objects from VBA, Visual Basic .NET, or C#.

The SharePoint objects are connected to the top-level Office document in each application. For example, the following lines each get a reference to the document workspace in Excel, Word, and PowerPoint, respectively, from within VBA:

    Set wsXL = ActiveWorkbook.SharedWorkspace
    Set wsWord = ActiveDocument.SharedWorkspace
    Set wsPPT = ActivePresentation.SharedWorkspace

From the document object, the SharePoint objects are organized as shown in Figure 10-1.

Office objects for SharePoint Services

Figure 10-1. Office objects for SharePoint Services

From VBA

Use the SharedWorkspace object to create, get, or delete a SharePoint document workspace site. The technique is the same for any of the supported document types. For example, to create a new workspace:

  1. Save the document.

  2. Call the SharedWorkspace object's CreateNew method to create the document workspace.

  3. Use the document's SharedWorkspace object to add members, tasks, links, files, or folders.

Chapter 5 demonstrates performing a wide range of SharePoint tasks with an Excel workbook using the SharedWorkspace object in VBA. It also shows how to share lists between Excel and SharePoint through VBA. Table 10-3 lists frequently asked questions to provide a quick ...

Get Essential SharePoint now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.