Thanks for that reference. I ended up using the AutoText method. I was
having trouble making the Settings.txt method work with this one, I
don't know why.
Larry
Here's what I did. The first macro creates an AutoText entry with the
name of the active document. Then, after I've activated another
document, and want to return to the first, I run the second macro which
takes me back to the first document.
The reason I wanted this was, often I have a bunch of documents open,
I'm working on one main document, then going to some other document, and
then I either have to cycle through the documents to get back to the
main document, or else open the Window menu to look for the window
number of the main document and press that. I wanted something that
would be automatically and in one step take me back to the document I
was working on.
Sub DocNameStore()
Application.ScreenUpdating = False
ActiveWindow.SplitVertical = 50
Selection.EndKey wdStory
Selection.InsertAfter ActiveDocument.Name
NormalTemplate.AutoTextEntries.Add Name:="MyDocName",
Range:=Selection.Range
Selection.TypeBackspace
ActiveWindow.SplitVertical = 100
End Sub
Sub PrevDocActivate()
Dim PrevDocName As String
PrevDocName = NormalTemplate.AutoTextEntries("MyDocName").Value
Documents(PrevDocName).Activate
End Sub
> Thanks for that reference. I ended up using the AutoText method. I
> was having trouble making the Settings.txt method work with this one,
[quoted text clipped - 3 lines]
>
> > Larry,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbawd10
> /html/wohowstoringvalues.asp
> >
[quoted text clipped - 16 lines]
> > > Thanks,
> > > Larry
Larry - 28 Nov 2004 15:14 GMT
This is better. Now the operation has no effect on the on-screen
appearance of the document.
Sub DocNameStore()
Dim X As Long, Y As Long
Dim r As Range
X = ActiveDocument.Range.End - 1
ActiveDocument.Range.InsertAfter ActiveDocument.Name
Y = ActiveDocument.Range.End - 1
Set r = ActiveDocument.Range(Start:=X, End:=Y)
NormalTemplate.AutoTextEntries.Add Name:="MyDocName", Range:=r
r.Delete
End Sub
> Here's what I did. The first macro creates an AutoText entry with the
> name of the active document. Then, after I've activated another
[quoted text clipped - 37 lines]
> >
> > > Larry,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbawd10
> > /html/wohowstoringvalues.asp
> > >
[quoted text clipped - 16 lines]
> > > > Thanks,
> > > > Larry
Tony - 02 Dec 2004 15:25 GMT
You can also use ProfileString (storing in registry) to
store the information e.g.
System.ProfileString("SubkeyName", "EntryName") = "Value"
MsgBox System.ProfileString("SubkeyName", "EntryName")
or store the information in normal.dot as a document
variable e.g.
Sub Test000()
ScreenUpdating = False
With NormalTemplate.OpenAsDocument
.Variables.Add Name:="UserName",
Value:=Application.UserName
.Close SaveChanges:=wdSaveChanges
End With
ScreenUpdating = True
End Sub
Grtz, Tony
>-----Original Message-----
>
[quoted text clipped - 79 lines]
>
>.