Partager via


Columns::Item method

The Item method returns the Column object at a specified index.

Syntax

Columns.Item( _
  ByVal Index As Long _
) As Column

Parameters

Index

The index of the column being retrieved. The index is 1-based.

Examples

' This example code writes Column information to a file.
'
' Obtain a Columns collection.
' objView is the active view of the Document object.
Dim objCols As MMC20.Columns
Set objCols = objView.Columns
 
' Determine the number of columns in the view.
Dim nCols As Long
nCols = objCols.Count
' Open an output file for the column information.
Open "D:\columns.txt" For Output As 1
' Write a header for the column information.
Print #1, "Display Position, Name, Hidden, IsSortColumn, Width"
' Declare variables for iterating the Columns collection.
Dim i As Long
Dim objCol As MMC20.Column
' Iterate the Columns collection.
For i = 1 To nCols
    ' Obtain the Column object by index.
    Set objCol = objCols.Item(i)
    'Write the column information to a file.
    Print #1, objCol.DisplayPosition, _
              objCol.Name, _
              objCol.Hidden, _
              objCol.IsSortColumn, _
              objCol.Width
    ' Free the Column object.
    Set objCol = Nothing
Next i
' Close the output file.
Close 1
 
' Free the Columns collection.
Set objCols = Nothing

Requirements

Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008
Header
MMCObj.h
IDL
MMCObj.idl
DLL
Mmc.exe
IID
IID_Columns is defined as 383D4D97-FC44-478B-B139-6323DC48611C

See also

Columns.Count