1. Trang chủ >
  2. Công Nghệ Thông Tin >
  3. Quản trị mạng >

Figure G-1. The Error Checking tab

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (5.72 MB, 490 trang )

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






IRtdServer; Path: Application -


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






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



Range - PivotCell - PivotItemList





ColumnItems() As PivotItemList

CustomSubtotalFunction() As


DataField() As PivotField

PivotCellType() As XlPivotCellType

PivotField() As PivotField

PivotItem() As PivotItem

PivotTable() As PivotTable

Range() As Range

Item(Index As Variant)

As PivotItem


RowItems() As PivotItemList

Count() As Long

New to Excel XP is the PivotCell object, which represents a cell in a pivot table. For more on this

object (and the PivotItemList object), please see Chapter 20.

Protection Object

Path: Application






Worksheet - Protection


AllowDeletingColumns() As Boolean

AllowDeletingRows() As Boolean

AllowEditRanges() As AllowEditRanges

AllowFiltering() As Boolean

AllowFormattingCells() As Boolean

AllowFormattingColumns() As Boolean

AllowFormattingRows() As Boolean

AllowInsertingColumns() As Boolean

AllowInsertingHyperlinks() As Boolean

AllowInsertingRows() As Boolean

AllowSorting() As Boolean

AllowUsingPivotTables() As Boolean

When you protect a worksheet, Excel permits you to specify that certain operations are still

permitted on unlocked cells. At the user level, this is done through the Protection dialog box. At

the programming level, it is done through the properties of the Protection object.

RTD Object

Path: Application - RTD







ThrottleInterval() As Long

The RTD object represents a real-time data object, a subject that we do not cover in this book.


SmartTag Related Objects

Path: Application -- Range -- SmartTags - SmartTag

SmartTagActions -- SmartTagAction;

Path: Application -- Workbook -- SmartTagOptions;

Path: Application -- SmartTagRecognizers SmartTagRecognizer




DownloadURL() As String

Name() As String

Properties() As


Range() As Range

SmartTagActions() As


XML() As String


Add(SmartTagType As

String) As SmartTag

Count() As Long


Name() As String

Count() As Long

Item(Index As Variant) As


DisplaySmartTags() As


EmbedSmartTags() As


Enabled() As Boolean

FullName() As String

progID() As String

Count() As Long

Item(Index As Variant) As


Recognize() As Boolean









This collection of objects enables programmatic control over existing Smart Tags. Note that in

order to create custom Smart Tags, we need need to use an application that can create COM DLLs,

such as Visual Basic or Visual C++. Custom Smart Tags cannot be created in Excel XP. For more

on Smart Tags, please see Chapter 22.

Speech Object


Path: Application - Speech




Speak(Text As String, [SpeakAsync] As

Variant, [SpeakXML] As Variant, [Purge] As



Direction() As


SpeakCellOnEnter() As


The Speech object is a very simple object that is used to implement speech in Excel XP. To obtain

a Speech object, use the Speech property of the Application object. The Speech object has only

two properties, Direction and SpeakCellOnEnter, and one method, Speak.

The Direction property sets the speech direction to one of the constants in the following enum:

Enum XlSpeakDirection

xlSpeakByRows = 0

xlSpeakByColumns = 1

End Enum

This sets the speech direction when using the Speak property of the Range object. For instance, if

the activesheet has content:

A1 = 1, B1 = 2

A2 = 3, B2 = 4

Then the code:

Range("A1:B2").Speak xlSpeakByRows

will speak "1, 2, 3, 4"

whereas the code:

Range("A1:B2").Speak xlSpeakByColumns

will speak "1, 3, 2, 4"

The SpeakCellOnEnter property is a Boolean property that specifies whether or not Excel will

speak the contents of the active cell when the Enter key is struck or when the focus moves to

another cell after editing of that cell. (The cell contents are not spoken just because focus is lost—

it only happens when the cell has been edited and focus is lost.)

The Speak method speaks text, as in:

Application.Speech.Speak "To be or not to be"


Application.Speech.Speak ActiveSheet.Range("A1").Value


SpellingOptions Object

Path: Application - SpellingOptions




ArabicModes() As XlArabicModes

DictLang() As Long

GermanPostReform() As Boolean

HebrewModes() As XlHebrewModes

IgnoreCaps() As Boolean

IgnoreFileNames() As Boolean

IgnoreMixedDigits() As Boolean

KoreanCombineAux() As Boolean

KoreanProcessCompound() As Boolean

KoreanUseAutoChangeList() As Boolean

SuggestMainOnly() As Boolean

UserDict() As String

The SpellingOptions object, returned by the SpellingOptions property of the Application object,

can set options for Excel's spell checking feature. The object has no methods, and its properties

generally correspond to the options available through the Spelling tab of Excel's Options dialog.

Tab Object

Path: Application


Chart - Tab




Color() As Variant

ColorIndex() As XlColorIndex

The ability to change the color of worksheet and chart tabs is new for Excel XP. This is done

through the user interface by right-clicking on a tab and choosing Tab Color from the popup menu.

To change the color programmatically, we can write code such as:

Worksheets("Sheet2").Tab.Color = vbGreen

The Tab object is returned by the Tab property of the Worksheet and the chart objects, and it has

Color and ColorIndex properties that can set the color.

UsedObjects Object

Path: Application - UsedObjects





Count() As Long

Item(Index As Variant) As Object

The documentation for the UsedObjects collection object is incredibly bad, even by Microsoft

standards, which is saying a lot. It gives absolutely no clue as to what used objects might be, but it

does tell us how to count the number of used objects!

If you open a brand new workbook (with the default three empty worksheets), then the code:


returns the number 7, so whatever is used object might be, there are 7 of them in a new workbook.

After some experimentation and much frustration, I conclude that if Microsoft does not consider it

worth spending time to write even a sentence explaining used objects, then it is probably not

worth your time or mine to try to figure it out.

UserAccessList andUserAccess Objects

Path: Application -- Range -- Worksheet --- AllowEditRanges -AllowEditRange -- UserAccessList - UserAccess







Add(Name As String, AllowEdit As

Boolean) As UserAccess



AllowEdit() As Boolean

Name() As String

Count() As Long

Item(Index As Variant)

As UserAccess

UserAccess objects allow certain users to access a protected range without requiring the password.

Watch Object

Path: Application





Watches - Watch




Source() As Variant

Add(Source As Variant) As Watch


Count() As Long

Item(Index As Variant) As Watch


The Excel XP Watch window toolbar is a very simple, yet useful tool. It enables the user to view

the contents of a cell even when the portion of the worksheet that contains the cell is not visible.

Figure G-2 shows the Watch Window Toolbar.

Figure G-2. The Watch Window

The Watch object implements the Watch Window programmatically.

The Watches property of the Application object returns a Watches collection that contains all of

the open Watch objects. The Watch object itself has only one really useful property—the Source

property, which specifies the cell to watch. The Watch object has only one method—Delete,

which deletes the watch.

To illustrate, the watch in Figure G-2 can be created in either of the following ways:

Dim wa As Watch

Set wa = Application.Watches.Add("A1")

Set wa = Application.Watches.Add(Range("A1"))



Our look is the result of reader comments, our own experimentation, and feedback from

distribution channels. Distinctive covers complement our distinctive approach to technical topics,

breathing personality and life into potentially dry subjects.

The animal on the cover of Writing Excel Macros with VBA, Second Edition, is a blue jay

(Cyanocitta cristata), a vociferous, aggressive bird common in the eastern half of the United

States and southern Canada. The blue-crested jay is also an agile flyer and occasional nest-robber.

The term "blue jay" is also applied to the Steller's jay (Cyanocitta stelleri), a larger, darker jay

common in much of the western U.S. and Canada, as well as several other species.

Blue jays eat primarily nuts, seeds, and insects, sometimes planting acorns in the ground, thus

helping tree growth. Known for their loud, harsh, and easily identifiable calls, blue jays (related to

crows and ravens) often spoil the hunting forays of other animals by warning potential prey.

Blue jays are bright blue, white, and black, with both sexes similar in appearance. They are about

10 to 12 inches in length, and build large tree nests about 25 feet off the ground, into which are

laid 3 to 6 spotted olive-colored eggs. The male is very attentive during the nesting periods. Jays

are sociable and frequently travel in groups, ranging from a mating pair to a larger flock.

Catherine Morris was the production editor and Tatiana Apandi Diaz was the proofreader for

Writing Excel Macros with VBA, Second Edition. Darren Kelly and Claire Cloutier provided

quality control. Joe Wizda wrote the index. Interior composition was done by Sarah Sherman and

Catherine Morris.

Hanna Dyer designed the cover of this book, based on a series design by Edie Freedman. The

cover image is a 19th-century engraving from the Dover Pictorial Archive. Emma Colby produced

the cover layout with QuarkXPress 4.1 using Adobe's ITC Garamond font.

David Futato designed the interior layout. This book was converted to FrameMaker 5.5.6 with a

format conversion tool created by Erik Ray, Jason McIntosh, Neil Walls, and Mike Sierra that

uses Perl and XML technologies. The text font is Linotype Birka; the heading font is Adobe

Myriad Condensed; and the code font is LucasFont's TheSans Mono Condensed. The illustrations

that appear in the book were produced by Robert Romano and Jessamyn Read using Macromedia

FreeHand 9 and Adobe Photoshop 6. The tip and warning icons were drawn by Christopher Bing.

This colophon was written by Nancy Kotary.

The online edition of this book was created by the Safari production group (John Chodacki, Becki

Maisch, and Madeleine Newell) using a set of Frame-to-XML conversion and cleanup tools

written and maintained by Erik Ray, Benn Salter, John Chodacki, and Jeff Liggett.


Xem Thêm
Tải bản đầy đủ (.pdf) (490 trang)