View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Alex Alex is offline
external usenet poster
 
Posts: 12
Default 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