Filehost.ro - gazduire fisiere
Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Nou pe simpatie:
LaraTaner
Femeie
24 ani
Prahova
cauta Barbat
24 - 52 ani
Mrrrr's Forum (VIEW ONLY)ReguliInregistrareLoginPozeNu sunteti logat. Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides /

[WORD] Remember Cursor Position to Go To It Later [VBA]

Pagini: 1 Moderat de TRaP, TonyTzu
#1
TRaP
Moderator
Postari: 960
I haven't been able to find a way to do this with a variable, but the simplest way to do this is with bookmarks.


'if bookmark exists, delete it, then add for current cursor position
Sub BookmarkAddHere()
If ActiveDocument.Bookmarks.Exists("CursorPosition") Then
    ActiveDocument.Bookmarks.Item("CursorPosition").Delete
End If
    ActiveDocument.Bookmarks.Add "CursorPosition", Selection.Range
End Sub

'go to bookmark for how many times you want
Sub BookmarkGoTo()
    Selection.GoTo what:=wdGoToBookmark, Name:="CursorPosition"
End Sub


The AddBookmarkHere snippet could be added to a Public Document_Close() procedure so it always remembers the last cursor position in every document.

Likewise, the BookmarkGoTo snippet could be added to a Public Document_Open() procedure so it always jumps to the last cursor position in every document.


 
   
Pagini: 1  
Mergi la