RHumana123
New Member
- Joined
- Apr 3, 2018
- Messages
- 1
Hello. I have some VB code that saves a file in read only. What I want to do is save over it daily. I am using Office 2016 and would like to know how to "resave" over the 'read only' file daily. Here is the subroutine I am using:
Sub ReadOnlyFile()
On Error Resume Next 'Keeps going if there is an error
Application.DisplayAlerts = False
Workbooks.Open "\\USERDAT10\RMA5800\Desktop\TEST\TestSaveReadOnlyCGXComboSnapshot.xlsx"
ActiveWorkbook.RefreshAll
ActiveWorkbook.Save
ActiveWorkbook.SaveCopyAs "\\USERDAT10\RMA5800\Desktop\TEST\Daily\TestSaveReadOnly.xlsx"
VBA.SetAttr "\\USERDAT10\RMA5800\Desktop\TEST\Daily\TestSaveReadOnly.xlsx", vbReadOnly
ActiveWorkbook.Close
End Sub
Sub ReadOnlyFile()
On Error Resume Next 'Keeps going if there is an error
Application.DisplayAlerts = False
Workbooks.Open "\\USERDAT10\RMA5800\Desktop\TEST\TestSaveReadOnlyCGXComboSnapshot.xlsx"
ActiveWorkbook.RefreshAll
ActiveWorkbook.Save
ActiveWorkbook.SaveCopyAs "\\USERDAT10\RMA5800\Desktop\TEST\Daily\TestSaveReadOnly.xlsx"
VBA.SetAttr "\\USERDAT10\RMA5800\Desktop\TEST\Daily\TestSaveReadOnly.xlsx", vbReadOnly
ActiveWorkbook.Close
End Sub