Chapter 8. Opening, Saving, and Sharing Workbooks

Workbooks represent documents in Excel. Use the Workbooks collection to create new documents, to open existing ones, or to perform operations on all open documents. Use the Workbook object to add worksheets and to save or otherwise change a single, open document.

The Workbook object is one of the central objects in Excel and most of the code you write will use Workbook in some way. Partly because of this, the Workbook object is also complex, providing more than 150 different properties and methods as well as two dozen or so events. I’ve tried to lay out the most common tasks in this chapter first, before delving into those details.

In this chapter, I show how to:

  • Create new workbooks and open existing ones

  • Save changes to a workbook and close without saving

  • Base a new workbook on a template

  • Create workbooks from text files

  • Create workbooks from XML data

  • Share a single workbook among multiple users

  • Use a workbook as part of a shared workspace through a SharePoint server

  • Respond to events that occur within a workbook

This chapter includes task-oriented reference information for the following objects and their related collections: Workbook and RecentFile.


Code used in this chapter and additional samples are available in ch08.xls.

Get Programming Excel with VBA and .NET now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.