Read only

T

Tim

Hello All,

I would like to open a read-only file, update a query,
make the file NOT read-only, save with the updated query,
then make read-only again.

I have the code to do the updates etc. Just not sure if
I can somehow temporarily make the workbook Un read-only.

Thanks
 
M

Michel Pierron

Hi Tim;
For example:

Sub WbkAcces()
With ThisWorkbook
If GetAttr(.FullName) And vbReadOnly Then SetAttr .FullName, vbNormal
If .ReadOnly Then .ChangeFileAccess xlReadWrite
End If
End With
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
SetAttr ThisWorkbook.FullName, vbReadOnly
End Sub

MP
 
Top