Word.Range.TextVisibleOnScreen? [英] Word.Range.TextVisibleOnScreen?
问题描述
Word.Range.TextVisibleOnScreen属性实际起作用吗?
Does the Word.Range.TextVisibleOnScreen property actually work?
Private Sub isVisTest()
Dim rng As Range: Set rng = oDoc.Bookmarks("_Toc#########").Range
'replace ######### with a good Heading bookmark number from your test document
Dim c As Integer
ActiveWindow.VerticalPercentScrolled = 0
ActiveWindow.HorizontalPercentScrolled = 0
oDoc.ActiveWindow.ScrollIntoView rng
Do
oDoc.ActiveWindow.SmallScroll Down:=6
Debug.Print rng.TextVisibleOnScreen
c = c + 1
If c > 10 Then Exit Do
Loop Until rng.TextVisibleOnScreen = 0
oDoc.ActiveWindow.SmallScroll Up:=6
End Sub
缩写过程使用标题"书签在屏幕顶部显示相应的标题.simto Word的内置导航窗格行为. Do-Loop是将Heading移至页面顶部的一种改进,但是我发现rng.TextVisibleOnScreen属性永远不会更改,而不管rng对象是否在屏幕上实际可见;总是-1.因此,该属性似乎被禁用.但是, MSDN 不会不会将其报告为已禁用或已弃用.
The abbreviated procedure uses Heading bookmark to display the corresponding Heading at the top of the screen simto Word's built-in Nav Pane behavior. The Do-Loop is a refinement to bring the Heading to top of page but I'm finding that the rng.TextVisibleOnScreen property never changes regardless of whether the rng object is actually visible onscreen or not; it's always -1. Thus the property seems disabled. However, MSDN doesn't report it as being disabled or deprecated.
可以使用选择"和IDE的即时"窗口(即?Selection.Range.TextVisibleOnScreen)来完成相同的测试.我得到相同的结果;始终为-1.
The same test can be done by using a Selection and the IDE's Immediate window, i.e., ?Selection.Range.TextVisibleOnScreen. I get the same result; always -1.