Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2006
    Thanked 0 Times in 0 Posts

    Export queries as Read Only (AccessXP)

    I am exporting some Access queries to .TXT files. I would like to make all the .TXT files "Read Only". Is there a way to set this property when exporting records?

    If not, is it possible to run some code over all the .TXT files in a folder and make them all "Read Only"?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Export queries as Read Only (AccessXP)

    The export from Access doesn't have an option to make a file read-only. You can use code like this to make all .txt files in a folder read-only:
    Dim strPath As String
    Dim fso As Object
    Dim fld As Object
    Dim fil As Object
    ' Modify as needed
    strPath = "C:MyFolder"
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set fld = fso.GetFolder(strPath)
    For Each fil In fld.Files
    If Right(fil.Name, 4) = ".txt" Then
    fil.Attributes = fil.Attributes Or 1 ' readonly
    End If
    Next fil
    Set fil = Nothing
    Set fld = Nothing
    Set fso = Nothing</code>

Posting Permissions

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