MRU List event

  • Thread starter Wes from Scottsdale
  • Start date
W

Wes from Scottsdale

I trying to integrate a DMS to use Word's Most Recently Used document list.

I need to perform some logic on the MRU entry to determine if the document
was opened from our DMS or from a local disk.

Can anyone point me in the directon of the event I need to use to perform
some code when an MRU entry is clicked?

Thanks.
Wes
 
D

DaveLett

Hi Wes,
Because clicking a recently used file is using a File Open event, you might
start with the article "Intercepting events like Save and Print" at
http://word.mvps.org/FAQs/MacrosVBA/InterceptSavePrint.htm

After that, you can set up the logic that you need by cycling through the
RecentFiles, as in the following:

Dim rfile As RecentFile
For Each rfile In RecentFiles
Debug.Print rfile.Path & "\" & rfile.Name
Next rfile
 
W

Wes from Scottsdale

Opening a file from the Recent Documents list does not use FileOpen. To test
this, I created a simple sub named FileOpen that throws a message box. When
I click the Open menu item, the message box appears. If I click on item in
the MRU List, the message box does not appear. Can you verify this as well?

At this point, I can't get any code to fire when a document is opened from
the MRU List. Can you provide more information on how Word interprets the
click event in the MRU List?

Thanks,
Wes
 
D

DaveLett

Hi Wes,
You're right, it's not FileOpen, but it is the Document_Open event
procedure, which you can also intercept. I found the following in the VBA
help:

This example displays a message when a document is opened. (The procedure
can be stored in the ThisDocument class module of a document or its attached
template.)

Visual Basic for Applications
Private Sub Document_Open()
MsgBox "This document is copyrighted."
End Sub

After testing, I would say that you MUST save this in the ThisDocument class
module. However, if you don't place this in that class module for ALL of your
templates, then your effort won't really pay off.

Dave
 
W

Wes from Scottsdale

I think the Document_Open event fires after the document has been loaded.

I need to intercept the event prior to Word loading the document, because I
need to run some logic so Word knows if it should be opened from my DMS or a
local disk.

Any other suggestions?

Thanks again
Wes
 
M

Manfred F

hi Wes,

Wes from Scottsdale said:
I need to intercept the event prior to Word loading the document, because I
need to run some logic so Word knows if it should be opened from my DMS or a
local disk.

I also use a kind of DMS. In their word Add-In, they use the <application>
events DocumentOpen for preparing the document content and
WindowActivate/WindowDeactivate to handle the GUI. They do not need to do
anything prior to opening a document, because the meta data is already
present as an xml file near the document.
I doubt, that You can intercept the MRU function. You can disable it
(setting the no. of entries to 0), maybe You can use some tricks via windows
API functions (intercept mouse events and check the cursor position on the
menu..?).


Good luck!
Manfred
 

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