Code Panes Collection Properties

Name Returns

Description

Current CodePane Hidden. Read-only. Returns the currently active

CodePane, and is the same as Application.VBE .ActiveCodePane.

Chapter 26 contains many CodePane examples. The following example identifies the current selection and centers it in the CodePane window:

Sub CenterSelectionInWindow() Dim oCP As VBIDE.CodePane Dim lStartLine As Long, lEndLine As Long Dim lVisibleLines As Long, lNewTop As Long

'Get the active CodePane

Set oCP = Application.VBE.ActiveCodePane

'Using the CodePane object... With oCP

'Get the start and end lines of the selection .GetSelection lStartLine, 0, lEndLine, 0

'How many lines fit in the window? lVisibleLines = .CountOfVisibleLines

'So what should the new top line be?

0 0

Post a comment