PDA

View Full Version : Solved: Document Access



Levski
05-14-2005, 02:03 AM
Is it possible I can prevent a document from appearing on the windows recent Documents list (not the Word recent files list); alternatively, could I password protect the file so it does not open without the correct password rather than just protecting the content from the Tools menu?

Thanks in advance

Levski :banghead:

Killian
05-14-2005, 05:10 AM
Hi levski,

preventing a document from appearing on the windows recent Documents list isn't as straight forward as you might have hoped...
It's easy enough to set a registry value to stop anything being added, or to clear the list, but this will affect all apps and users. Finding the specific enrty presents two challenges:
First, both the file name and parent folder path are stored in separate keys, in binary. There are also equivalent shortcuts saved in the users recent document folder.
Secondly, you can run code on the document_close event but this will fire BEFORE the file is added to the list, so it's not really going to work with document level code.

Additionally, a user can open a Word doc without enebling macros, by-passing any security features you may add.

If you have a documents you want to restrict access to, the most robust (and simplest) method would be save them to a windows directory that has specific user permissions set.

MOS MASTER
05-14-2005, 09:33 AM
Hi Lev, :D

Like Killian is saying this is a Window's thing and while in Word is not that easy to manipulate.

I think you could make a list of Word document's that are made in a current Word session this list could be written to a txtfile or something.

Then the next time Word starts you can use a AutoExec macro to delete all the shortcuts out of the recent file list.

To me this does seam like a crapy sollution and I think you should go with the document protection method!

Saving with password to open protection is easy like:
Sub SaveIt()
Dim sPath As String

sPath = ThisDocument.Path & Application.PathSeparator & "Test.doc"
Application.ActiveDocument.SaveAs FileName:=sPath, _
FileFormat:=wdFormatDocument, Password:="Joost"

End Sub


Enjoy! :whistle:

Levski
05-14-2005, 02:18 PM
As long as the documents are passworded I don't mind them appearing on the list. Security requirements aren't such that I want to make permission calls and have the application log in as admin, so your code is pretty much what I wanted. A few niggles aside that I think I can probably find the parameters to at msdn, I think I am pretty much done! :cloud9:

Thanks again for all the help.

MOS MASTER
05-14-2005, 02:20 PM
Hi Levski, :D
You're Welcome! :beerchug: