View Single Post
  #1   Report Post  
Larry
 
Posts: n/a
Default How to make doc's FullName into an AutoText entry without first inserting it into document


This macro works fine. It temporarily Inserts Fullname of the active
document into the document and makes that string an AutoText entry
called MyDocName, which is used later by another macro to reactivate
this document from another document. This enables me to return
instantly to this document without having to open the Window menu or
scroll through the open documents. But I wonder if there is a more
efficient way of doing it, so that the active document's FullName
doesn't actually have to be inserted into the document as a range, but
rather the FullName becomes an AutoText entry in one step. It seems
that would make the macro a little faster.

Any ideas? Thanks.
Larry
..

Sub DocFullNameStore()

Application.ScreenUpdating = False
Dim X As Long, Y As Long
Dim r As Range

X = ActiveDocument.Range.End - 1
ActiveDocument.Range.InsertAfter ActiveDocument.FullName
Y = ActiveDocument.Range.End - 1
Set r = ActiveDocument.Range(Start:=X, End:=Y)
NormalTemplate.AutoTextEntries.Add Name:="MyDocFullName", Range:=r
r.Delete

End Sub