Results 1 to 2 of 2

Thread: setting attribute-files with VBA for excel

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    12

    setting attribute-files with VBA for excel

    How can I set a file-attribute with VBA for excel ? (eg Read-only)
    Thanks in advance
    Satch

  2. #2
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    you could use the FileSytemObject class..

    like this:

    VB Code:
    1. Private Sub Form_Load()
    2.     Dim fso As New FileSystemObject
    3.     Dim f As File
    4.    
    5.     Set f = fso.GetFile("C:\bob.txt")
    6.    
    7.     'Since all read-only files should have an attributes property that
    8.     'is an odd no, this should work...
    9.     If (f.Attributes And 1) = 0 Then f.Attributes = f.Attributes + 1
    10.    
    11.     Set fso = Nothing
    12. End Sub

    NOTE: You'll need to set a reference to the Microsoft Scripting Run-time for this to work
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width