![]() |
|
#1
|
|||
|
|||
|
Is that possible realise with vba? When i start ms word i need to open doc with previous position of cursos. Maybe something like autocreat bukmark when exit and autogo to it from the start?
|
|
#2
|
||||
|
||||
|
Pressing Shift-F5 when you open a document will take you to the last edit. You don't need vba for this.
IIRC, Office 2007 didn't originally support that, but it was fixed with a service pack. If not, see: http://www.vbaexpress.com/forum/cont...you-re-open-it
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
Just when edited, but doesn't remember the last page when just viewing document?
|
|
#4
|
||||
|
||||
|
The link in my previous reply refers to a macro that can restore the functionality for Word 2007.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#5
|
|||
|
|||
|
the template is right? It still doesn't work for me. No hidden bookmark created
|
|
#6
|
||||
|
||||
|
The bookmark is created in the document being edited, not in the template. But none of that is going to happen if you don't follow the instructions in the link. Your attachment shows quite clearly you haven't done that.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#7
|
|||
|
|||
|
Code:
Option Explicit
Sub FileSave()
On Error Resume Next
ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:="OpenAt"
ActiveDocument.Save
InsertDocTitle
End Sub
Sub FileSaveAs()
On Error Resume Next
ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:="OpenAt"
Dialogs(wdDialogFileSaveAs).Show
InsertDocTitle
End Sub
Sub AutoOpen()
On Error Resume Next
With ActiveWindow.View
If Err.Number = 4248 Then Exit Sub
.Type = wdPrintView
.Zoom = 100
.TableGridlines = True
End With
ActiveWindow.ActivePane.View.ShowAll = False
ActiveWindow.ActivePane.View.ShowFieldCodes = False
If ActiveDocument.Bookmarks.Exists("OpenAt") = True Then
ActiveDocument.Bookmarks("OpenAt").Select
End If
InsertDocTitle
End Sub
Sub InsertDocTitle()
' Changes window title to include path with filename
Dim NameArray As Variant
Dim NameStringL As String
Dim NameStringR As String
Dim Count As Long
Const maxLen = 120 ' set this value to fit your window width
' (avoid error if no active window)
If Windows.Count > 0 Then
NameStringL = ActiveDocument.FullName
If Len(NameStringL) > maxLen Then
' separate the folder names
NameArray = Split(NameStringL, "\")
' check the folder depth
Count = UBound(NameArray)
If Count > 3 Then
NameStringL = NameArray(0) & "\...\"
NameStringR = NameArray(Count)
Count = Count - 1
' continue adding folders to the left of the string
' until you run out of folders or one won't fit
Do While (Count > 0) And _
(Len(NameStringL) + Len(NameStringR) + _
Len(NameArray(Count)) < maxLen)
NameStringR = NameArray(Count) & "\" _
& NameStringR
Count = Count - 1
Loop
NameStringL = NameStringL & NameStringR
End If
End If
' Change the window's caption
ActiveWindow.Caption = NameStringL
End If
End Sub
|
|
#8
|
||||
|
||||
|
There is nothing wrong with the code in the link. It is your implementation that is the problem, solely because you haven't followed the instructions.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Header - same as previous
|
dianabanana | Word | 5 | 04-28-2014 06:03 AM |
reference previous heading1
|
fehenry | Word | 5 | 04-20-2012 01:54 AM |
VBA: how can I know the position on a document?
|
tinfanide | Excel Programming | 3 | 02-27-2012 03:24 PM |
| fix position for a segment in a doc | tai | Word | 3 | 10-20-2011 01:04 PM |
| Previous Doc pops up | Les Harris | Word | 1 | 01-19-2009 04:48 PM |