The Workbook Object

A Workbook object represents an open Excel workbook. As we have discussed, Workbook objects are stored in a Workbooks collection.

The Workbook object has a total of 103 properties and methods, as shown in Table 17-1.

Table 17-1. Members of the Workbook object

_CodeName

FullName

RefreshAll

_PrintOut<v9>

FullNameURLEncoded<v 10>

Rej ectAllChanges

_Protect<v10>

HasMailer

ReloadAs<v9>

_ReadOnlyRecommended<v 10>

HasPassword

RemovePersonalInformation<v 10>

_SaveAs<v10>

HasRoutingSlip

RemoveUser

AcceptAllChanges

HighlightChangesOnScreen

Reply

AcceptLabelsInFormulas

HighlightChangesOptions

ReplyAll

Activate

HTMLProj ect<v9>

ReplyWithChanges<v 10>

ActiveChart

IsAddin

ResetColors

Active Sheet

IsInplace

RevisionNumber

AddToFavorites

KeepChangeHistory

Route

Application

Keywords

Routed

Author

Linklnfo

RoutingSlip

AutoUpdateFrequency

LinkSources

RunAutoMacros

AutoUpdateSaveChanges

ListChangesOnNewSheet

Save

BreakLink<v10>

Mailer

SaveAs

BuiltinDocumentProperties

MergeWorkbook

SaveCopyAs

Calculation Version<v9>

Modules

Saved

CanCheckIn<v10>

MultiUserEditing

SaveLinkValues

ChangeFileAccess

Name

sblt<v9>

ChangeHistoryDuration

Names

SendForReview<v 10>

ChangeLink

NewWindow

SendMail

Charts

OnSave

SendMailer

CheckIn<v10>

OnSheetActivate

SetLinkOnData

Close

OnSheetDeactivate

SetPasswordEncryptionOptions<v10>

CodeName

OpenLinks

Sheets

Colors

Parent

ShowConflictHistory

CommandBars

Password<v10>

ShowPivotTableFieldList<v 10>

Comments

PasswordEncryptionAlgorithm<v10>

SmartTagOptions<v 10>

ConflictResolution

PasswordEncryptionFileProperties<v 10>

Styles

Container

PasswordEncryptionKeyLength<v 10>

Subject

CreateBackup

PasswordEncryptionProvider<v10>

TemplateRemoveExtData

Creator

Path

Title

CustomDocumentProperties

PersonalViewListSettings

Unprotect

Custom Views

PersonalViewPrintSettings

UnprotectSharing

Date 1904

PivotCaches

UpdateFromFile

DeleteNumberFormat

PivotT able Wizard

UpdateLink

Dialog Sheets

Post

UpdateLinks<v10>

DisplayDrawingObjects

PrecisionAsDisplayed

UpdateRemoteReferences

Dummy 16<v 10>

PrintOut

UserControl

Dummy 17<v 10>

PrintPreview

UserStatus

EnableAutoRecover<v 10>

Protect

VBASigned<v9>

EndReview<v 10>

ProtectSharing

VBProject

EnvelopeVisible<v9>

ProtectStructure

WebOptions<v9>

Excel4IntlMacro Sheets

ProtectWindows

WebPagePreview<v9>

Excel4Macro Sheets

PublishObj ects<v9>

Windows

ExclusiveAccess

PurgeChangeHistoryNow

Worksheets

FileFormat

ReadOnly

WritePassword<v10>

FollowHyperlink

ReadOnlyRecommended

WriteReserved

ForwardMailer

RecheckSmartTags<v10>

WriteReservedBy

Several of the members listed in Table 17-1 exist solely to return the children of the Workbook object. The children are shown in Figure 17-4.

Figure 17-4. Children of the Workbook object

7 □ Woikbook

To

Chert

?U

CustomViews

?B

Mailer

4-

?u

; Irsmes

+

?u

PiwOfOflChBE

+

?u

PublishObjerts<v9>

?D

Roulirig Slip

+

?u

Sh self.

To

Srn 8r1_d j Op1i.. i Iii vi Ü >

+

?u

Styles

?o

W8b0pliüns<v9>

?o

Window

?U

Wind ewe

+

?o

Worksheet

Table 17-2 gives the members of the Workbook object that return children.

Table 17-2. Members of Workbook that return children

Name

ReturnType

ActiveChart

Chart

Application

Application

Charts

Sheets

Custom Views

Custom Views

DialogSheets

Sheets

Excel4IntlMacro Sheets

Sheets

Excel4Macro Sheets

Sheets

Mailer

Mailer

Modules

Sheets

Names

Names

NewWindow

Window

PivotCaches

PivotCaches

PublishObjects

PublishObjects

Routing Slip

Routing Slip

Sheets

Sheets

SmartTagOptions

SmartTagOptions

Styles

Styles

WebOptions

WebOptions

Windows

Windows

Worksheets

Sheets

There are a few items worth noting about Table 17-2. First, the ActiveSheet property may return either a Chart object or a Worksheet object, depending upon what type of object is currently active.

Second, the Charts, Sheets, and Worksheets properties all return a (different) Sheets collection. In particular, the Charts object returns the Sheets collection that contains all of the chart sheets in the workbook. (This does not include charts that are embedded in worksheets.) The Worksheets property returns the Sheets collection of all worksheets in the workbook. Finally, the Sheets property returns the Sheets collection of all worksheets and chart sheets. This is a relatively rare example of a collection that contains objects of more than one type. Note that there is no Sheet object in the Excel object model.

Let us look at a few of the more commonly used members from Table 17-1.

0 0

Post a comment