Saturday, 20 December 2014

Microsfot Excel - Macro - How to make file read only

Watch this example on YouTube

The following code will make file read only

Sub TestFile()
    Dim FileName As String
    Dim FileObject As Object
    Dim FileSystem As Object
    FileName = "C:\Temp\ExcelTest\ReadOnly.txt"
    Set FileObject = CreateObject("Scripting.FileSystemObject")
    Set FileSystem = FileObject.GetFile(FilePath:=FileName)
    FileSystem.Attributes = 1
End Sub

No comments:

Post a Comment