PDA

View Full Version : Viewing text above and below the insertion point



mdmackillop
04-10-2008, 01:09 PM
When I scroll up or down, I'd like to see the text before the insertion point reaches it. I've resolved how to do this in Excel (demo file attached), but can it also be done in Word?

chandansify
04-11-2008, 07:19 AM
When I scroll up or down, I'd like to see the text before the insertion point reaches it. I've resolved how to do this in Excel (demo file attached), but can it also be done in Word?

Hi MD,

I tried a thing and somehow able to mimic the similar concept in MS Word.
It is not like rows but percentage.


Check and see if it works for you.


Thanks,
Chandan

mdmackillop
04-11-2008, 10:38 AM
Thanks,
It works great in page layout view, but stops responding when I go up to line 1 in Normal view. I've not checked out the code in detail, but at a quick glance looks good (not over complex)
Regards
Malcolm

fumei
04-11-2008, 12:50 PM
I do not think it will work in Normal view.

mdmackillop
04-11-2008, 12:53 PM
I'll check it out now.

mdmackillop
04-11-2008, 02:11 PM
Just needed an escape from the While loop

Sub PerformScrolling(sAction As String)
Dim pTop As Long, pLeft As Long, pHeight As Long, pWidth As Long
Dim pScreenHeight As Long, Chk As Long
On Error GoTo err1
ActiveWindow.GetPoint pLeft, pTop, pWidth, pHeight, Selection.Range
pScreenHeight = System.VerticalResolution
If sAction = "Up" Then
Chk = pTop
While pTop - (pScreenHeight * pUpPercentage / 100) < 0 ' pScreenHeight
ActiveWindow.SmallScroll Up:=1
ActiveWindow.GetPoint pLeft, pTop, pWidth, pHeight, Selection.Range
If pTop = Chk Then '<== Escape the loop if no movement
Selection.MoveUp
Exit Sub
End If
Wend
Selection.MoveUp
ElseIf sAction = "Down" Then
While pTop + (pScreenHeight * pDownPercentage / 100) > pScreenHeight
ActiveWindow.SmallScroll 1
ActiveWindow.GetPoint pLeft, pTop, pWidth, pHeight, Selection.Range
Wend
Selection.MoveDown
End If
Exit Sub
err1:
If sAction = "Up" Then
Selection.MoveUp
ElseIf sAction = "Down" Then
Selection.MoveDown
End If
End Sub

chandansify
04-11-2008, 06:35 PM
Just needed an escape from the While loop

Sub PerformScrolling(sAction As String)
Dim pTop As Long, pLeft As Long, pHeight As Long, pWidth As Long
Dim pScreenHeight As Long, Chk As Long
On Error GoTo err1
ActiveWindow.GetPoint pLeft, pTop, pWidth, pHeight, Selection.Range
pScreenHeight = System.VerticalResolution
If sAction = "Up" Then
Chk = pTop
While pTop - (pScreenHeight * pUpPercentage / 100) < 0 ' pScreenHeight
ActiveWindow.SmallScroll Up:=1
ActiveWindow.GetPoint pLeft, pTop, pWidth, pHeight, Selection.Range
If pTop = Chk Then '<== Escape the loop if no movement
Selection.MoveUp
Exit Sub
End If
Wend
Selection.MoveUp
ElseIf sAction = "Down" Then
While pTop + (pScreenHeight * pDownPercentage / 100) > pScreenHeight
ActiveWindow.SmallScroll 1
ActiveWindow.GetPoint pLeft, pTop, pWidth, pHeight, Selection.Range
Wend
Selection.MoveDown
End If
Exit Sub
err1:
If sAction = "Up" Then
Selection.MoveUp
ElseIf sAction = "Down" Then
Selection.MoveDown
End If
End Sub




Thanks MD for this task.

I got crazy doing this and I love it. Do you have more task similar to this.

mdmackillop
04-12-2008, 01:28 AM
If you're keen, why not complete this by expanding it to deal with Left/Right scrolling and submit it as a KB item. That is my intention with the Excel version.
Regards
MD

mdmackillop
04-12-2008, 01:55 AM
I got crazy doing this and I love it. Do you have more task similar to this.
What I would do is to look at the Word Forum and sort by number of views. You can see what most searchers are looking at. Find something interesting and create a general solution that can be added to the KB.
Have a look at this example (http://www.vbaexpress.com/forum/showthread.php?t=790).
I created a KB Search function for use in Excel. Maybe you could convert it for use in Word with a presentation in a table, or maybe even an inset spreadsheet. Feel free to make use of my existing code (with a reference of course!)
Regards
MD

chandansify
04-12-2008, 05:48 AM
What I would do is to look at the Word Forum and sort by number of views. You can see what most searchers are looking at. Find something interesting and create a general solution that can be added to the KB.
Have a look at this example (http://www.vbaexpress.com/forum/showthread.php?t=790).
I created a KB Search function for use in Excel. Maybe you could convert it for use in Word with a presentation in a table, or maybe even an inset spreadsheet. Feel free to make use of my existing code (with a reference of course!)
Regards
MD


Thanks,

Sure I'll try this.

Cheers...

fumei
04-14-2008, 06:03 AM
Hey Malcolm. I am not fully understanding what you are asking for. The link is to creating hyperlinks on an Index. How does that relate to your:

"What I would do is to look at the Word Forum and sort by number of views. "

mdmackillop
04-14-2008, 06:34 AM
Hi Gerry,
I added a quote to my previous post to clarify. I meant the development of a question into a KB item or the lilke.


I got crazy doing this and I love it. Do you have more task similar to this.