Word VBA教程:Item方法

应用于 Borders对象的 Item方法。

返回指定区域或所选内容中的一个边框。

expression.Item(Index)

expression   必需。该表达式返回一个Borders对象。

Index  WdBorderType,必需。返回的边框。

WdBorderType 可以是下列 WdBorderType 常量之一:
wdBorderBottom
wdBorderDiagonalDown
wdBorderDiagonalUp
wdBorderHorizontal
wdBorderLeft
wdBorderRight
wdBorderTop
wdBorderVertical

应用于 Dialogs对象的 Item方法。

返回 Microsoft Word 中的一个对话框。

expression.Item(Index)

expression   必需。该表达式返回一个Dialogs对象。

Index  WdWordDialog,必需。指定对话框的常量。

WdWordDialog 可以是下列 WdWordDialog 常量之一:
wdDialogMailMergeInsertSet
wdDialogConnect
wdDialogConsistencyChecker
wdDialogControlRun
wdDialogConvertObject
wdDialogCopyFile
wdDialogCreateAutoText
wdDialogDocumentStatistics
wdDialogDrawAlign
wdDialogDrawSnapToGrid
wdDialogEditAutoText
wdDialogEditCreatePublisher
wdDialogEditFind
wdDialogEditFrame
wdDialogEditGoTo
wdDialogEditGoToOld
wdDialogEditLinks
wdDialogEditObject
wdDialogEditPasteSpecial
wdDialogEditPublishOptions
wdDialogEditReplace
wdDialogEditStyle
wdDialogEditSubscribeOptions
wdDialogEditSubscribeTo
wdDialogEditTOACategory
wdDialogEmailOptions
wdDialogFileDocumentLayout
wdDialogFileFind
wdDialogFileMacCustomPageSetupGX
wdDialogFileMacPageSetup
wdDialogFileMacPageSetupGX
wdDialogFileNew
wdDialogFileOpen
wdDialogFilePageSetup
wdDialogFilePrint
wdDialogFilePrintOneCopy
wdDialogFilePrintSetup
wdDialogFileRoutingSlip
wdDialogFileSaveAs
wdDialogFileSaveVersion
wdDialogFileSummaryInfo
wdDialogFileVersions
wdDialogFitText
wdDialogFontSubstitution
wdDialogFormatAddrFonts
wdDialogFormatBordersAndShading
wdDialogFormatBulletsAndNumbering
wdDialogFormatCallout
wdDialogFormatChangeCase
wdDialogFormatColumns
wdDialogFormatDefineStyleBorders
wdDialogFormatDefineStyleFont
wdDialogFormatDefineStyleFrame
wdDialogFormatDefineStyleLang
wdDialogFormatDefineStylePara
wdDialogFormatDefineStyleTabs
wdDialogFormatDrawingObject
wdDialogFormatDropCap
wdDialogFormatEncloseCharacters
wdDialogFormatFont
wdDialogFormatFrame
wdDialogFormatPageNumber
wdDialogFormatParagraph
wdDialogFormatPicture
wdDialogFormatRetAddrFonts
wdDialogFormatSectionLayout
wdDialogFormatStyle
wdDialogFormatStyleGallery
wdDialogFormatStylesCustom
wdDialogFormatTabs
wdDialogFormatTheme
wdDialogFormFieldHelp
wdDialogFormFieldOptions
wdDialogFrameSetProperties
wdDialogHelpAbout
wdDialogHelpWordPerfectHelp
wdDialogHelpWordPerfectHelpOptions
wdDialogHorizontalInVertical
wdDialogIMESetDefault
wdDialogInsertAddCaption
wdDialogInsertAutoCaption
wdDialogInsertBookmark
wdDialogInsertBreak
wdDialogInsertCaption
wdDialogInsertCaptionNumbering
wdDialogInsertCrossReference
wdDialogInsertDatabase
wdDialogInsertDateTime
wdDialogInsertField
wdDialogInsertFile
wdDialogInsertFootnote
wdDialogInsertFormField
wdDialogInsertHyperlink
wdDialogInsertIndex
wdDialogInsertIndexAndTables
wdDialogInsertMergeField
wdDialogInsertNumber
wdDialogInsertObject
wdDialogInsertPageNumbers
wdDialogInsertPicture
wdDialogInsertSubdocument
wdDialogInsertSymbol
wdDialogInsertTableOfAuthorities
wdDialogInsertTableOfContents
wdDialogInsertTableOfFigures
wdDialogLetterWizard
wdDialogListCommands
wdDialogMailMerge
wdDialogMailMergeCheck
wdDialogMailMergeCreateDataSource
wdDialogMailMergeCreateHeaderSource
wdDialogMailMergeFieldMapping
wdDialogMailMergeFindRecord
wdDialogMailMergeHelper
wdDialogMailMergeInsertAddressBlock
wdDialogMailMergeInsertAsk
wdDialogMailMergeInsertFields
wdDialogMailMergeInsertFillIn
wdDialogMailMergeInsertGreetingLine
wdDialogMailMergeInsertIf
wdDialogMailMergeInsertNextIf
wdDialogMailMergeInsertSkipIf
wdDialogMailMergeOpenDataSource
wdDialogMailMergeOpenHeaderSource
wdDialogMailMergeQueryOptions
wdDialogMailMergeRecipients
wdDialogMailMergeUseAddressBook
wdDialogMarkCitation
wdDialogMarkIndexEntry
wdDialogMarkTableOfContentsEntry
wdDialogNewToolbar
wdDialogNoteOptions
wdDialogOrganizer
wdDialogPhoneticGuide
wdDialogReviewAfmtRevisions
wdDialogSearch
wdDialogTableAutoFormat
wdDialogTableCellOptions
wdDialogTableColumnWidth
wdDialogTableDeleteCells
wdDialogTableFormatCell
wdDialogTableFormula
wdDialogTableInsertCells
wdDialogTableInsertRow
wdDialogTableInsertTable
wdDialogTableOfCaptionsOptions
wdDialogTableOfContentsOptions
wdDialogTableProperties
wdDialogTableRowHeight
wdDialogTableSort
wdDialogTableSplitCells
wdDialogTableTableOptions
wdDialogTableToText
wdDialogTableWrapping
wdDialogTCSCTranslator
wdDialogTextToTable
wdDialogToolsAcceptRejectChanges
wdDialogToolsAdvancedSettings
wdDialogToolsAutoCorrect
wdDialogToolsAutoCorrectExceptions
wdDialogToolsAutoManager
wdDialogToolsAutoSummarize
wdDialogToolsBulletsNumbers
wdDialogToolsCompareDocuments
wdDialogToolsCreateDirectory
wdDialogToolsCreateEnvelope
wdDialogToolsCreateLabels
wdDialogToolsCustomize
wdDialogToolsCustomizeKeyboard
wdDialogToolsCustomizeMenuBar
wdDialogToolsCustomizeMenus
wdDialogToolsDictionary
wdDialogToolsEnvelopesAndLabels
wdDialogToolsHangulHanjaConversion
wdDialogToolsHighlightChanges
wdDialogToolsHyphenation
wdDialogToolsLanguage
wdDialogToolsMacro
wdDialogToolsMacroRecord
wdDialogToolsManageFields
wdDialogToolsMergeDocuments
wdDialogToolsOptions
wdDialogToolsOptionsAutoFormat
wdDialogToolsOptionsAutoFormatAsYouType
wdDialogToolsOptionsBidi
wdDialogToolsOptionsCompatibility
wdDialogToolsOptionsEdit
wdDialogToolsOptionsFileLocations
wdDialogToolsOptionsFuzzy
wdDialogToolsOptionsGeneral
wdDialogToolsOptionsPrint
wdDialogToolsOptionsSave
wdDialogToolsOptionsSpellingAndGrammar
wdDialogToolsOptionsTrackChanges
wdDialogToolsOptionsTypography
wdDialogToolsOptionsUserInfo
wdDialogToolsOptionsView
wdDialogToolsProtectDocument
wdDialogToolsProtectSection
wdDialogToolsRevisions
wdDialogToolsSpellingAndGrammar
wdDialogToolsTemplates
wdDialogToolsThesaurus
wdDialogToolsUnprotectDocument
wdDialogToolsWordCount
wdDialogTwoLinesInOne
wdDialogUpdateTOC
wdDialogViewZoom
wdDialogWebOptions
wdDialogWindowActivate

应用于 HeadersFooters对象的 Item方法。

返回指定区域或所选内容的页眉或页脚。

expression.Item(Index)

expression   必需。该表达式返回一个HeadersFooters对象。

Index  WdHeaderFooterIndex,必需。指定所选内容中页眉或页脚的常量。

WdHeaderFooterIndex 可以是下列 WdHeaderFooterIndex 常量之一:
wdHeaderFooterEvenPages
wdHeaderFooterFirstPage
wdHeaderFooterPrimary

应用于 ListGalleries对象的 Item方法。

从列表模板库中返回列表类型(项目符号、编号或多级列表)。

expression.Item(Index)

expression   必需。该表达式返回一个ListGalleries对象。

Index  WdListGalleryType,必需。指定列表类型的常量。

WdListGalleryType 可以是下列 WdListGalleryType 常量之一:
wdBulletGallery
wdNumberGallery
wdOutlineNumberGallery

应用于 MappedDataFields对象的 Item方法。

返回一个指定的映射数据域。

expression.Item(Index)

expression   必需。该表达式返回一个MappedDataFields对象。

Index  WdMappedDataFields,必需。指定的映射数据域。

WdMappedDataFields 可以是下列 WdMappedDataFields 常量之一:
wdAddress1
wdAddress2
wdBusinessFax
wdBusinessPhone
wdCity
wdCompany
wdCountryRegion
wdCoutesyTitle
wdEmailAddress
wdFirstName
wdHomeFax
wdHomePhone
wdJobTitle
wdLastName
wdMiddleName
wdNickname
wdPostalCode
wdSpouseCourtesyTitle
wdSpouseFirstName
wdSpouseLastName
wdSpouseMiddleName
wdSpouseNickname
wdState
wdSuffix
wdUniqueIdentifier
wdWebPageURL

应用于 StoryRanges对象的 Item方法。

将所选区域或内容的单个文字部分作为Range对象返回。

expression.Item(Index)

expression   必需。该表达式返回一个StoryRanges对象。

Index  WdStoryType,指定的文字部分类型。

WdStoryType 可以是下列 WdStoryType 常量之一:
wdCommentsStory
wdEndnotesStory
wdEvenPagesFooterStory
wdEvenPagesHeaderStory
wdFirstPageFooterStory
wdFirstPageHeaderStory
wdFootnotesStory
wdMainTextStory
wdPrimaryFooterStory
wdPrimaryHeaderStory
wdTextFrameStory

应用于 TaskPanes对象的 Item方法。

将指定任务窗格作为TaskPane对象返回。

expression.Item(Index)

expression   必需。该表达式返回一个TaskPanes对象。

Index  WdTaskPanes,必需。指定的任务窗格。

WdTaskPanes 可以是下列 WdTaskPanes 常量之一:
wdTaskPaneFormatting
wdTaskPaneInspector
wdTaskPaneMailMerge
wdTaskPaneSearch
wdTaskPaneTranslate

应用于 Zooms对象的 Item方法。

返回指定的Zoom对象。

expression.Item(Index)

expression   必需。该表达式返回一个Zooms对象。

Index  WdViewType,必需。指定的缩放类型。

WdViewType 可以是下列 WdViewType 常量之一:
wdMasterView
wdNormalView
wdOutlineView
wdPrintPreview
wdPrintView
wdWebView
应用于“应用于”列表中所有其他对象的 Item方法。

返回集合中的个别对象。

expression.Item(Index)

expression   必需。该表达式返回以上列表中的一个对象。

Index  Variant 或 Long 类型,必需。返回的个别对象。

对于下列对象,Index 可以是 Variant 类型的值,表明常规位置;或是一个字符串,代表个别对象的名称。

AddIns
AutoCaptions
AutoCorrectEntries
AutoTextEntries
Bookmarks
CanvasShapes
CaptionLabels
CustomLabels
CustomProperties
DiagramNodeChildren
DiagramNodes
Dictionaries
Documents
EmailSignatureEntries
FileConverters
FirstLetterExceptions
FormFields
GroupShapes
HangulAndAlphabetExceptions
HangulHanjaConversionDictionaries
Hyperlinks
Languages
ListEntries
ListTemplates
MailMergeDataFields
MailMergeFieldNames
OtherCorrectionsExceptions
ReadabilityStatistics
Reviewers
ShapeRange
Shapes
ShapeNodes
SmartTags
Styles
StyleSheets
TablesOfAuthoritiesCategories
TabStops
Tasks
Templates
TwoInitialCapsExceptions
Variables
Windows

对于下列对象,Index 可以是 Long 类型的值,表明个别对象的常规位置。

Adjustments
Cells
Characters
Columns
Comments
Endnotes
Fields
FontNames
Footnotes
Frames
HeadingStyles
HTMLDivisions
Indexes
InlineShapes
KeyBindings
KeysBoundTo
Lists
ListLevels
ListParagraphs
MailMergeFields
PageNumbers
Panes
Paragraphs
ProofreadingErrors
RecentFiles
Revisions
Rows
Sections
Sentences
SpellingSuggestions
Subdocuments
Tables
TablesOfAuthorities
TablesOfContents
TablesOfFigures
TextColumns
Versions
Words

VBA示例

应用于 Bookmarks对象的 Item方法。

本示例选定活动文档中名为“temp”的书签。


Sub BookmarkItem()
    If ActiveDocument.Bookmarks.Exists("temp") = True Then
        ActiveDocument.Bookmarks.Item("temp").Select
    End If
End Sub

应用于 Borders对象的 Item方法。

本示例在活动文档的第一段之上插入双边框。


Sub BorderItem()
    ActiveDocument.Paragraphs(1).Borders.Item(wdBorderTop) _
        .LineStyle = wdLineStyleDouble
End Sub

应用于 Dialogs对象的 Item方法。

本示例显示“页面设置”对话框。


Sub DialogItem()
    Application.Dialogs.Item(wdDialogFileDocumentLayout).Display
End Sub

应用于 Documents对象的 Item方法。

本示例显示 Documents集合的第一篇文档的名字。


Sub DocumentItem()
    If Documents.Count >= 1 Then
        MsgBox Documents.Item(1).Name
    End If
End Sub

应用于 HeadersFooters对象的 Item方法。

本示例在活动文档中创建首页页眉并设置其格式。


Sub HeadFootItem()
    ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True
    With ActiveDocument.Sections(1).Headers _
            .Item(wdHeaderFooterFirstPage).Range
        .InsertBefore "Sales Report"
        With .Font
            .Bold = True
            .Size = "15"
            .Color = wdColorBlue
        End With
        .Paragraphs.Alignment = wdAlignParagraphCenter
    End With
End Sub

当应用于 ListEntries对象时。

本示例首先清除名为“Colors”的下拉型窗体域中的各项,然后添加两个颜色名。Item方法用来显示下拉型窗体域的第一个颜色。


Sub ListEntryItem()
    Dim d As DropDown
    Set d = ActiveDocument.FormFields.Add _
        (Range:=Selection.Range, _
        Type:=wdFieldFormDropDown).DropDown
    With d.ListEntries
        .Add Name:="Black"
        .Add Name:="Green"
    End With
    MsgBox d.ListEntries.Item(1).Name
End Sub

Word VBA教程

Word VBA参考教程:目录1 Word VBA参考教程:目录2
Word VBA参考教程:目录3 Word VBA参考教程:目录4
Word VBA参考教程:目录5 Word VBA参考教程:目录6
Word VBA参考教程:目录7 Word VBA参考教程:目录8
Word VBA参考教程:目录9 Word VBA参考教程:目录10
版权所有 © 中山市飞娥软件工作室 证书:粤ICP备09170368号

Word VBA参考教程