MS Word: Auto Reading

L

Legacy 65404

Guest
Hi, I'm trying to make a macro in MSWord to "Auto Read" a document, I use a code to page down once, and a delay. I've put it on a while, but I can't check if the cursor is at the end of the file, does anybody know how to verify if the cursor is in the last line?

or, if doesn't, do you guys know a forum as good as this one for MSWord (I don't think that it exists, but at least a good forum.. :wink: )

Thanks,
Guilherme
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I want the document to roll down automatically in a cartain delay, so you can read it without pressing any key, I already have this code, what I need is to check if it's on the end of the document, so I can stop my code.
 
Upvote 0
OIC :)
I am sure there are better solutions, but until I look at your code, here is a quick and dirty work-around. Just nest your code in On Error Resume/Go statment and then handle the Error generated by hitting the end of the document. Here is an example:
Code:
Sub Example()
Dim lngErrNum As Long
On Error GoTo Err_Hnd
lngErrNum = 1234 'Change this to the correct error number.

'***************
'Your Code Here*
'***************

Exit Sub
Err_Hnd:
If Err.Number = lngErrNum Then
    'Do Whatever
    Else
    MsgBox Err.Description, vbCritical, "Error: " & Err.Number
    End If
End Sub
 
Upvote 0
well, let me see if I can explain with the code...

Code:
Sub Test()
    Do While   'Here I want to know when the file ends
        Selection.MoveDown Unit:=wdScreen, Count:=1
        Call subDelay(20)
    Loop
End Sub

I used a function to delay:

Code:
Public Sub subDelay(sngDelay As Single)
    Const cSecondsInDay = 86400

    Dim sngStart As Single 
    Dim sngStop  As Single 
    Dim sngNow   As Single 

    sngStart = Timer 
    sngStop = sngStart + sngDelay 
    Do
        sngNow = Timer 
        If sngNow < sngStart Then 
            sngStop = sngStart - cSecondsInDay
        End If
        DoEvents
    Loop While sngNow < sngStop
End Sub

This is what I need: On the while of the first code (sub test()) I have to check if the cursor is at the last line of the document... so I can stop the code.

Was I clear? I'm sorry if I wasn't, explaining something in english is not very easy to me...

Thanks for the help until now,
Guilherme
 
Upvote 0

Forum statistics

Threads
1,214,631
Messages
6,120,645
Members
448,974
Latest member
DumbFinanceBro

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top