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

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
L

Legacy 65404

Guest
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.
 

Oorang

Well-known Member
Joined
Mar 4, 2005
Messages
2,071
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
 
L

Legacy 65404

Guest
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
 

Forum statistics

Threads
1,136,354
Messages
5,675,301
Members
419,560
Latest member
g3org

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
Top