is file available for editing ?

  • Thread starter Thread starter LeeL
  • Start date Start date
here is one way

Dim x As String
x = Excel.Workbooks("book1").ReadOnly = True
If x = "True" Then
MsgBox "File is Read Only"
Else
MsgBox "File is available for editing"
End If
 
Thanks, just one quick question, how to form the x stament for a text file ?
For example "H:\log.txt"
 
this may better suit your needs - adjust the path and filename either
manually of with a variable and the code will tell u if the file is avialable
for editing and the file type does not matter


Sub tst()
Dim myfilename As String
myfilename = "C:\Documents and Settings\1006646\Desktop\26022h.txt"

x = GetAttr(myfilename) And vbReadOnly
If x = 1 Then
MsgBox "file is read only'"
Else: MsgBox "file is avialable for edit"
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top