Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 09-14-2014, 03:35 AM
Dimsok Dimsok is offline Start from the previous position Windows XP Start from the previous position Office 2007
Advanced Beginner
Start from the previous position
 
Join Date: Sep 2014
Location: exUSSR
Posts: 50
Dimsok is on a distinguished road
Default

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
Can you please change the code that "OpenAt" bookmark was hidden and the 5th to delete that bookmark?
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Start from the previous position Header - same as previous dianabanana Word 5 04-28-2014 06:03 AM
Start from the previous position reference previous heading1 fehenry Word 5 04-20-2012 01:54 AM
Start from the previous position 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

Other Forums: Access Forums

All times are GMT -7. The time now is 11:59 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft