SelInfo()

Syntax

SelInfo(Type)

Remarks

Returns one of 37 types of information about the selection, where Type is one of the values described in the following tables. In the explanations, the active end of the selection refers to the end that moves when you press SHIFT+an arrow key.

Type

Explanation

1

Number of the page containing the active end of the selection. If you set a starting page number or make other manual adjustments, returns the adjusted page number (unlike SelInfo(3)).

If the selection is in a header or footer pane in normal view, returns –1. If the selection is in a footnote or annotation pane, returns the page number of the first footnote or annotation in the selection.

2

Number of the section containing the active end of the selection.

3

Number of the page containing the active end of the selection, counting from the beginning of the document. Any manual adjustments to page numbering are disregarded (unlike SelInfo(1)).

4

Number of pages in the document.


Type 5 is valid only in page layout view. Type 6 is valid in page layout view or in normal view if you select the Background Repagination check box on the General tab and clear the Draft Font check box on the View tab in the Options dialog box (Tools menu).

Type

Explanation

5

Horizontal position of the selection; distance between the left edge of the selection and the left edge of the page, in twips (20 twips = 1 point, 72 points = 1 inch). Returns –1 if the selection is not visible.

6

Vertical position of the selection; distance between the top edge of the selection and the top edge of the page, in twips (20 twips = 1 point, 72 points = 1 inch). Returns –1 if the selection is not visible in the document window.


Types 7 and 8 are most useful in page layout view, where you can display text boundaries by selecting the Text Boundaries check box on the View tab in the Options dialog box (Tools menu). Text boundaries include table cells, frames, the edges of the page, text columns, and so on. For a complete list of text boundaries, see NextObject.

Type

Explanation

7

Horizontal position of the selection, relative to the left edge of the nearest text boundary enclosing it, in twips (20 twips = 1 point, 72 points = 1 inch). Returns –1 if selection is not visible.

8

Vertical position of the selection, relative to the upper edge of the nearest text boundary enclosing it, in twips (20 twips = 1 point, 72 points = 1 inch). Especially useful for determining the position of the insertion point within a frame or table cell. For a complete list of text boundaries, see NextObject. Returns –1 if the selection is not visible.

9

Character position of the first character in the selection or, if no text is selected, the character to the right of the insertion point (same as the character column number displayed in the status bar after "Col").

10

Line number of the first character in the selection; if Background Repagination is cleared or if Draft Font is selected, returns –1.

11

Returns –1 if the selection is an entire frame.

12

Returns –1 if the selection is within a table.


Types 13 through 18 apply only if the selection is within a table; if the selection is not within a table, the function returns –1.

Type

Explanation

13

The row number containing the beginning of the selection.

14

The row number containing the end of the selection.

15

The number of rows in the table.


Type

Explanation

16

The table column number containing the beginning of the selection.

17

The table column number containing the end of the selection.

18

The greatest number of columns within any row in the selection.


Types 19 through 37 return miscellaneous information.

Type

Explanation

19

The current percentage of magnification as set by ViewZoom.

20

The current selection mode: returns 0 (zero) for normal selection, 1 for extended selection, and 2 for column selection. Corresponds to the box in the status bar that reads either "EXT" or "COL."

21

Returns –1 if Caps Lock is in effect.

22

Returns –1 if Num Lock is in effect.

23

Returns –1 if Word is in overtype mode.

24

Returns –1 if revision marking is in effect.

25

Returns –1 if the selection is in the footnote or endnote pane, or in a footnote or endnote in page layout view. See also values 35 and 36.

26

Returns –1 if the selection is in an annotation pane.

27

Returns –1 if the selection is in a macro-editing window.

28

Returns –1 if the selection is in the header or footer pane or in a header or footer in page layout view.

29

The number of the bookmark enclosing the start of the selection; 0 (zero) if none or invalid. The number corresponds to the position of the bookmark in the document — 1 for the first bookmark, 2 for the second, and so on.

30

The number of the last bookmark that starts before or at the same place as the selection; returns 0 (zero) if none or invalid.

31

Returns –1 if the insertion point is at the end-of-row mark in a table.

32

Returns one of the following values, depending on where the selection is in relation to a footnote, endnote, or annotation reference:

–1 If the selection includes but is not limited to a footnote, endnote, or annotation reference

0 (zero) If the selection is not in a footnote, endnote, or annotation reference

1 If the selection is in a footnote reference

2 If the selection is in an endnote reference

3 If the selection is in an annotation reference


Type

Explanation

33

The kind of header or footer containing the selection:

–1 None (the selection is not in a header or footer)

0 (zero) Even-page header

1 Odd-page header (or the only header if there are not odd and even headers)

2 Even-page footers

3 Odd-page footer (or the footer if there are not odd and even footers)

4 First-page header

5 First-page footer

34

Returns –1 if the active document is a master document (that is, if it contains at least one subdocument)

35

Returns –1 if the selection is in the footnote pane or in a footnote in page layout view.

36

Same as 35, but for endnotes.

37

Returns one of the following values, depending on whether the current selection is in a WordMail message:

0 (zero) If the selection is not in a WordMail message

1 If the selection is in a WordMail send note

2 If the selection is in a WordMail read note


Examples

This example determines whether the current selection extends over a page break, either manual or automatic. Note that SelInfo(3) is used twice: once to return the page number of the end of the selection, and again to return the page number of the beginning of the selection. The macro is then able to compare these values to determine how many page breaks are in the selection.


ToolsRepaginate
EditBookmark .Name = "Tmp"
endPage = SelInfo(3)
SelType 1
startPage = SelInfo(3)
EditGoTo .Destination = "Tmp"
numBreaks = endPage - startPage
If numBreaks = 1 Then
    MsgBox "Selection extends over one page break."
ElseIf numBreaks > 1 Then
    MsgBox "Selection extends over" + Str$(numBreaks) + \
        " page breaks."
End If
EditBookmark .Name = "Tmp", .Delete

The following example increases the view magnification by 10 percent:


n = SelInfo(19)
If n < 190 Then
    ViewZoom .ZoomPercent = n + 10
ElseIf n = 200 Then
    MsgBox "Already zoomed to maximum."
Else
    ViewZoom .ZoomPercent = 200
End If

See Also

Selection$(), SelType