• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 822
  • Last Modified:

Word 2007 VBA - Reposition the cursor

I wish to save the current cursor position at the start of a macro subroutine and then at the end of the sub reposition the cursor where it started fromj.

How would I do this?

TIA
0
Philip Pinnell
Asked:
Philip Pinnell
1 Solution
 
jmdionCommented:
This should work:
Sub DoSomething()

    Dim position As Range
    Set position = Selection.Range.Duplicate

    ' Do other things

    
    position.Select
    
End Sub

Open in new window

0
 
Philip PinnellAuthor Commented:
Thanks. That seems to work a treat.
0
 
GrahamSkanRetiredCommented:
Not a direct answer, but it is usually possible, and, I think, better not to move the cursor during the macro.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now