The following example uses the ActiveCodePane property and TopLine properties to obtain the number of the top line in the active code pane.
Debug.Print Application.VBE.ActiveCodePane.TopLine