Change file to read-only

madhouse

Registered User.
Local time
Today, 23:56
Joined
Jul 3, 2002
Messages
65
Is it possible within MS Access to change the attribute of a file (a Word document for example) to read-only? If so, any ideas how this can be done?
 
Use the SetAttr Statement.

This will set the file to Read-Only...
Code:
SetAttr "C:\Temp\Test.doc", vbReadOnly

This will remove the Read-Only attribute...
Code:
SetAttr "C:\Temp\Test.doc", vbNormal

Check out the Access help files for the SetAttr Statement for more info and the other arguments.
 
ghudson - thanks for the reply....in both forums ;) Works perfectly.

I don't suppose, moving on a step, whether it's possible to go as far as actually giving a user authority to a file. For example, if a set of files in a directory were tied down so that no-one could use them except for Administrators. Then within MS Access I could give a user explicit authority to use and make changes to a file? I'm gonna guess that the answer is going to be no to this!! I'm just trying to find the best way to secure a set of files in a directory(s) and to only give a user(s) authority to them on request - the read-only idea was the best that I could come up with. I don't want to have to keep getting our IT department involved in adding/removing user authority because this "project" stems from the files on our AS400.
 
No, you can not alter the security settings of a network directory using VBA. You would have to set up the permissions with your IT folks. They could create different groups and each group could have different persmissions to the directory. Each user would have to be assigned to a group to get the permissions you want them to have. That would be an odd request but I do not know what your situation is since you want to control data files, not the database application. In most cases, a user can open, save or copy a file that they can open and move the file to their PC or portable thumbnail drive, etc. and change the attribute of the file and do what ever they want. If you can not trust them then they should not be working for your company.
 

Users who are viewing this thread

Back
Top Bottom