Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Read only vs file saving | Excel Discussion (Misc queries) | |||
Cannot remove Read Only Attribute | Excel Discussion (Misc queries) | |||
Cannot remove read only attribute | Excel Discussion (Misc queries) | |||
Tried changing a file attribute from read only but I get error msg | Excel Discussion (Misc queries) | |||
Read Only attribute disappears | Excel Discussion (Misc queries) |