How can I set a file-attribute with VBA for excel ? (eg Read-only)
Thanks in advance
Satch
Printable View
How can I set a file-attribute with VBA for excel ? (eg Read-only)
Thanks in advance
Satch
you could use the FileSytemObject class..
like this:
VB Code:
Private Sub Form_Load() Dim fso As New FileSystemObject Dim f As File Set f = fso.GetFile("C:\bob.txt") 'Since all read-only files should have an attributes property that 'is an odd no, this should work... If (f.Attributes And 1) = 0 Then f.Attributes = f.Attributes + 1 Set fso = Nothing End Sub
NOTE: You'll need to set a reference to the Microsoft Scripting Run-time for this to work