how to stop do loop macro when it reaches the last page of a word document
Posted on 2003-03-28
After doing a mail merge in word 97 one of the fields in the merged document contains numbers which are a shortcut for autotext entries ie.0001 is the short cut for one name and address, 0002 is the shortcut for another name and address and so on.
i use a "do loop" macro to update all the number fields in the merged document. However i do not know how to make the macro stop when it reaches the last autotext entry ie 0009. Instead the macro just hangs.Because i use various autotext numbers ie 0189 or 0847 i would like the loop macro to just end on the last page of the merged document irrespective of which autotext number has been entered.
The macro code is as follows:
Selection.MoveDown Unit:=wdLine, Count:=2
Selection.MoveRight Unit:=wdCharacter, Count:=1
Thanking you in anticipation to anyone who can help