O'Reilly logo

Programming Excel with VBA and .NET by Steve Saunders, Jeff Webb

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

Tip

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required