Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

Last ActiveDocument during a New event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fred - 14 Nov 2005 01:11 GMT
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
Jezebel - 14 Nov 2005 01:39 GMT
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?

>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

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.