Tải bản đầy đủ - 0 (trang)
Appendix G. New Objects in Excel XP

Appendix G. New Objects in Excel XP

Tải bản đầy đủ - 0trang

The AutoRecover object implements automatic recovery. Its Path property sets the location where

Excel will place the AutoRecover file and its Time property sets the time (in minutes) interval for

backing up the workbook to the AutoRecover file, as in:

Application.AutoRecover.Path = "d:\temp"

Application.AutoRecover.Time = 10' minutes



CalculatedMember Object

Path: Application -- Range -- PivotTable

CalculatedMembers - CalculatedMember



Object



Methods



CalculatedMember



CalculatedMembers





















Delete()













Add(Name As String

Formula As String

[SolveOrder] As Variant

[Type] As Variant) As

CalculatedMember









--



Properties

Formula() As String

IsValid() As Boolean

Name() As String

SolveOrder() As Long

SourceName() As String

Type() As

XlCalculatedMemberType



Count() As Long

Item(Index As Variant) As

CalculatedMember



The CalculatedMember object programmatically manipulates the calculated fields and calculated

items for PivotTables that are connected to external OLAP (Online Analytical Processing) data

sources. We will not discuss these data sources further in this book.



CellFormat Object

Path: Application - CellFormat



Object



CellFormat



Methods







Clear()



























Properties

AddIndent() As Variant

Borders() As Borders

Font() As Font

FormulaHidden() As Variant

HorizontalAlignment() As Variant

IndentLevel() As Variant

Interior() As Interior

Locked() As Variant

MergeCells() As Variant

NumberFormat() As Variant

NumberFormatLocal() As Variant



464













Orientation() As Variant

ShrinkToFit() As Variant

VerticalAlignment() As Variant

WrapText() As Variant



The CellFormat object works in conjunction with the FindFormat and ReplaceFormat objects to

programmatically find and replace cell formatting. For more on this, please see Chapter 16.



CustomProperty Object

Path: Application -- Range -- Worksheet

CustomProperties - CustomProperty



Object

CustomProperty



CustomProperties



--



Methods











Delete()







Add(Name As String, Value As

Variant) As CustomProperty









Properties

Name() As String

Value() As Variant

Count() As Long

Item(Index As Variant) As

CustomProperty



The Microsoft documentation, with its usual obscurity, states the following about the

CustomProperty object: "Represents identifier information. Identifier information can be used as

metadata for XML." However, the documentation does not bother to elaborate on how this

information can be used as metadata. In any case, it is not our intention in this book to cover the

XML-related features of Excel.

The CustomProperties collection holds CustomProperty objects.



Diagram, DiagramNode and DiagramNodeChildren Objects

Path: Application -- Chart -Diagram -- DiagramNodes -Diagram-Node-DiagramNodeChildren



Object



Shapes



--



Shape -



Methods







Diagram







Convert(Type As MsoDiagramType)











465



Properties

AutoFormat() As

MsoTriState

AutoLayout() As

MsoTriState

Nodes() As

DiagramNodes

Reverse() As

MsoTriState

Type() As



MsoDiagramType





AddNode(pos As

MsoRelativeNodePosition, nodeType

As MsoDiagramNodeType) As

DiagramNode

CloneNode(copyChildren As Boolean,

pTargetNode As DiagramNode, pos

As MsoRelativeNodePosition) As

DiagramNode

Delete()

MoveNode(pTargetNode As

DiagramNode, pos As

MsoRelativeNodePosition)

NextNode() As DiagramNode

PrevNode() As DiagramNode

ReplaceNode(pTargetNode As

DiagramNode)

SwapNode(pTargetNode As

DiagramNode, swapChildren As

Boolean)

TransferChildren(pReceivingNode As

DiagramNode)













DiagramNode

















DiagramNodes



Item(Index As Variant) As

DiagramNode

SelectAll()









AddNode(Index As Variant,

nodeType As MsoDiagramNodeType)

As DiagramNode

Item(Index As Variant) As

DiagramNode

SelectAll()







DiagramNodeChildren





















Children() As

DiagramNodeChil

dren

Diagram() As

IMsoDiagram

Layout() As

MsoOrgChartLay

outType

Root() As

DiagramNode

Shape() As Shape

TextShape() As

Shape







Count() As

Signed machine

int







Count() As

Signed machine

int

FirstChild() As

DiagramNode

LastChild() As

DiagramNode









Diagrams are special types of shapes that organize data visually. There are six types of diagrams,

including flow charts (organizational charts) and various types of relationship charts. The

Diagram-related objects programmatically create and edit diagrams. For more on this, please see

Appendix A, The Shape Object.



Error Object

Path: Application



--



Range



--



Errors - Error



Object

Error



Properties







Ignore() As Boolean

Value() As Boolean



466



Error objects determine whether or not a particular type of error has occurred in a specified range.

In particular, the Errors property of the Range object returns an Errors collection. This collection

always contains exactly seven Error objects, corresponding to the seven types of available errorchecking options, as shown in the Error Checking tab of the Options dialog box (see the

ErrorCheckingOptions entry).

The Error object has a Boolean, read-only Value property that is set to True by Excel if there is

an error of the type corresponding to the Error object within the given range.

It is important to note that, in order for the Error object's Value property to function correctly, the

error-checking option must be enabled, either programmatically or through the Error Checking tab.

To illustrate, the following code first turns on global empty cell error checking. Then in cell A1, it

places a formula that references one or more empty cells. Finally, the code checks to see if there is

an empty cell reference error within the range denoted by rng.

Sub Example_ErrorObject()

Dim rng As Range

Set rng = Application.Range("A1")

' Make sure empty cell error checking is on globally

Application.ErrorCheckingOptions.EmptyCellReferences = True



AM

FL

Y



' Insert formula referencing empty cells

' in a cell within the range rng

Range("A1").Formula = "=A12+A13"



TE



' Check to see if there is an empty cell type error in the

specified range

If rng.Errors.Item(xlEmptyCellReferences).Value = True Then

MsgBox "Empty cell error in range " & rng.Address

Else

MsgBox "No empty cell error in range " & rng.Address

End If

End Sub



Note that if we change the specified range to one that contains more than one cell, as in:

Set rng = Application.Range("A1:B2")



then the line:

If rng.Errors.Item(xlEmptyCellReferences).Value = True Then



generates a generic (and therefore totally useless) error message! There is certainly no reason why

the Errors property of the Range object could not work with multi-cell ranges and the

documentation mentions no such restriction. Of course, there is no way to tell whether there is

simply an omission in the documentation or an error in the Excel code. The only clue is that the

Error object does not have any properties that returns a list of the offending cells within the range.

This might lead us to believe that the Errors property was intended to apply only to one-cell

ranges.



467 ®

Team-Fly



ErrorCheckingOptions Object

Path: Application - ErrorCheckingOptions



Object





















ErrorCheckingOptions



Properties

BackgroundChecking() As Boolean

EmptyCellReferences() As Boolean

EvaluateToError() As Boolean

InconsistentFormula() As Boolean

IndicatorColorIndex() As XlColorIndex

NumberAsText() As Boolean

OmittedCells() As Boolean

TextDate() As Boolean

UnlockedFormulaCells() As Boolean



This object corresponds to the Error Checking tab under the Excel Options dialog box. The

ErrorCheckingOptions object's properties correspond to the check boxes in the aforementioned

dialog box tab, as shown in Figure G-1.

Figure G-1. The Error Checking tab



For instance, when the Boolean TextDate property of the ErrorCheckingOptions object is set to

True (corresponding to checking the check box labeled "Text date with 2 digit years"), Excel will

display an AutoCorrect options button next to text cells that express the year as a two-digit value

(rather than a four-digit value), for example Jan 1, 01.

The Errors collection object holds Error objects. The Errors object has the following members:



Properties





Item(Index As Variant) As Error



Graphic Object

Path: Application



Object



Graphic



--



Chart



--



PageSetup - Graphic



Properties





















Brightness() As Single

ColorType() As MsoPictureColorType

Contrast() As Single

CropBottom() As Single

CropLeft() As Single

CropRight() As Single

CropTop() As Single

Filename() As String

Height() As Single



468









LockAspectRatio() As MsoTriState

Width() As Single



The Graphic object allows the programmer to set various properties of images that can appear in

Excel headers and footers. For example, you can set the file name, image size and various color

aspects of the image, as well as its location in the header or footer.



IRTDServer and IRTDUpdateEvent Objects

Path: Application

IRTDUpdateEvent



Object











Disconnect()

UpdateNotify()













IRTDUpdateEvent



IRtdServer; Path: Application -



Method

ConnectData(TopicID As Long, Strings

As Array of Variant, GetNewValues As

Boolean) As Variant

DisconnectData(TopicID As Long)

Heartbeat() As Long

RefreshData(TopicCount As Long) As

Array of Variant

ServerStart(CallbackObject As

IRTDUpdateEvent) As Long

ServerTerminate()







IRtdServer



--



Properties







HeartbeatInterval()

As Long



The IRTDServer object and the IRTDUpdateEvent relate to real-time data servers, which we do

not cover in this book.



PivotCell and PivotItemList Objects

Path: Application



Object



--



Range - PivotCell - PivotItemList



Methods



















PivotCell



469



Properties

ColumnItems() As PivotItemList

CustomSubtotalFunction() As

XlConsolidationFunction

DataField() As PivotField

PivotCellType() As XlPivotCellType

PivotField() As PivotField

PivotItem() As PivotItem

PivotTable() As PivotTable

Range() As Range



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Appendix G. New Objects in Excel XP

Tải bản đầy đủ ngay(0 tr)

×
x