Somehow indicate last line in Word VBA -


i have macro use highlight lines of lists see step on. it's pretty simple. unhighlights current line , highlights next line.

sub highlight_next_row_down()     selection.endkey unit:=wdline     selection.homekey unit:=wdline, extend:=wdextend     selection.range.highlightcolorindex = wdnohighlight     selection.movedown unit:=wdline, count:=1     selection.endkey unit:=wdline     selection.homekey unit:=wdline, extend:=wdextend     selection.range.highlightcolorindex = wdyellow end sub 

now, want unhighlight current line when on last line of document, because finished. inserting if statement around whole thing (minus sub statements) first checks if it's last line. but, don't know how check if line last line. have googled , haven't found anything.

similarly, have "highlight_next_row_up" , want know how same when reach top line.

thanks help

i'm not sure if exact logic need code presenting 1 of possible way of checking if in last line of document.

sub highlight_next_row_down()     selection.endkey unit:=wdline     selection.homekey unit:=wdline, extend:=wdextend     'here check if end     if selection.end = activedocument.bookmarks("\endofdoc").range.end         'just unhighlight         selection.range.highlightcolorindex = wdnohighlight     else         'your code here         selection.range.highlightcolorindex = wdnohighlight         selection.movedown unit:=wdline, count:=1         selection.endkey unit:=wdline         selection.homekey unit:=wdline, extend:=wdextend         selection.range.highlightcolorindex = wdyellow     end if end sub 

please keep in mind additional empty paragraph moves end of document somewhere below last line of text.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -