Last ActiveDocument during a New event

F

Fred

I need to know which document was the Active document when a particular
template is opened, that is during the 'New' event of the template.

Thanks,
Fred
 
J

Jezebel

The problem is that once the New event fires, the new document is the active
one; and at this point, as far as I know, Word has no record of what was
previously the active document (if any at all). So you'll need to keep track
of it yourself.

On method is to write your own FileNew function --


Sub FileNew()
Dim pDoc As Word.Document
Set pDoc = ActiveDocument
Dialogs(wdDialogFileNew).Show
MsgBox "Previous was " & pDoc.Name
End Sub


Put this in normal.dot and it will run in place of the built-in command.
Another approach would be to use an add-in, to trap the Window
SelectionChange event - record the active document each time the window
select changes. Neither of these is a particularly elegant solution. Why do
you need to know it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top