At work, (I prepare medical transcriptions), Word pops up a demographic
screen. With the kind help of some of the people here, I have managed to put
together a macro that goes into that demographic screen, which is in
continuous break section 1, copy some information, and assign it to
Autocorrect entries. We enter text into continuous break section 2 only. The
document opens in section 2, and the macro starts out by typing in these
characters: <>, jumping to section 1 to do its magic, returning to the <>
characters in section 2, and then deleting them. The object of the exercise
is to put the cursor back exactly where it had been before the macro ran.
A slight problem is that when it goes back to the marker in section 2, that
part is now at the top of the screen. In other words, the view port has
changed. Is there a way of having it return to the <> marker, erase it, and
have the viewpoint at the same section of the screen? For example, if the
cursor was at line 15 when it typed out the <> marker, before the rest of the
macro ran, at the end I would like it to return to the marker, delete it, and
then reposition that back to line 15.
I hope this is clear.
Regards,
Alan
Helmut Weber - 04 Feb 2008 16:09 GMT
Hi Alan,
IMHO, not in a straighforward way.
There are things like:
ActiveWindow.SmallScroll down:=10
However, here and know, online help doesn't know it.
The key is, *not to go* anywhere at all,
but to use a range object instead of moving the selection.
Yes, easier said then done.
You might also consider splitting the document's window,
that is having section 1 in one window and
section 2 in another window.
But again, easier said then done.
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Vista Small Business, Office XP
Alan - 04 Feb 2008 20:52 GMT
Hi Helmut,
Thanks for your reply. I suspected that might be the case.
After looking around for an hour and a half, I did find something in this
group that was of some help and certainly more elegant than what I had come
up with on my own. I didn't copy the name or URL of the post in my notes,
but I copied the content of the note. Below is the content of the post.
Regards,
Alan Stancliff
************OTHER POST**********
Remember where the cursor is,
execute your macro, and go back.
Sub test0098()
Dim rTmp As Range
Set rTmp = Selection.Range
' execute code here or in another macro
rTmp.Select
End Sub
Which doesn't work,
if the original range isn't there anymore, of course.
Or if your code is in the same macro,
and does change rTmp.
> Hi Alan,
>
[quoted text clipped - 22 lines]
>
> Vista Small Business, Office XP