![]() |
Saving a file within a macro but only when it does not have a read only attribute
I have a spreadsheet that is updated overnight and is then available for
multiple users to see. The approach I am taking is this (I make no apologies for the fact there are probably a hundred better approaches to the one I am taking!!): 1. Run a DOS batch job that removes the read only attribute from the Excel file 2. Open the Excel file as a scheduled task. 3. The Excel file has an auto_open macro that updates some values and saves itself before closing 4. Run a DOS batch job that reapplies the read only attribute from the Excel file I am applying the read only attribute to allow multiple users to view the file without getting the notification message that someone is already accessing it. However, when the users open the file, it starts the Auto_open macro which in turn tries to save the file, but of course fails because the Read Only attribute is applied. How do I get the macro to only run if the file is not read only? Alternatively, if there are any better ways of achieving the above in a more sophisticated way, I'm all ears! Thanks in advance Alex |
Saving a file within a macro but only when it does not have a read only attribute
Public Sub Auto_Open()
if not ThisWorkbook.ReadOnly then ' existing code goes here End if End Sub -- Regards, Tom Ogilvy "Alex" <@ wrote in message ... I have a spreadsheet that is updated overnight and is then available for multiple users to see. The approach I am taking is this (I make no apologies for the fact there are probably a hundred better approaches to the one I am taking!!): 1. Run a DOS batch job that removes the read only attribute from the Excel file 2. Open the Excel file as a scheduled task. 3. The Excel file has an auto_open macro that updates some values and saves itself before closing 4. Run a DOS batch job that reapplies the read only attribute from the Excel file I am applying the read only attribute to allow multiple users to view the file without getting the notification message that someone is already accessing it. However, when the users open the file, it starts the Auto_open macro which in turn tries to save the file, but of course fails because the Read Only attribute is applied. How do I get the macro to only run if the file is not read only? Alternatively, if there are any better ways of achieving the above in a more sophisticated way, I'm all ears! Thanks in advance Alex |
Saving a file within a macro but only when it does not have a read only attribute
Perfect - Thanks a lot
"Tom Ogilvy" wrote in message ... Public Sub Auto_Open() if not ThisWorkbook.ReadOnly then ' existing code goes here End if End Sub -- Regards, Tom Ogilvy "Alex" <@ wrote in message ... I have a spreadsheet that is updated overnight and is then available for multiple users to see. The approach I am taking is this (I make no apologies for the fact there are probably a hundred better approaches to the one I am taking!!): 1. Run a DOS batch job that removes the read only attribute from the Excel file 2. Open the Excel file as a scheduled task. 3. The Excel file has an auto_open macro that updates some values and saves itself before closing 4. Run a DOS batch job that reapplies the read only attribute from the Excel file I am applying the read only attribute to allow multiple users to view the file without getting the notification message that someone is already accessing it. However, when the users open the file, it starts the Auto_open macro which in turn tries to save the file, but of course fails because the Read Only attribute is applied. How do I get the macro to only run if the file is not read only? Alternatively, if there are any better ways of achieving the above in a more sophisticated way, I'm all ears! Thanks in advance Alex |
All times are GMT +1. The time now is 01:52 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com