Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Read only vs file saving Rich D Excel Discussion (Misc queries) 1 October 23rd 07 03:50 PM
Cannot remove Read Only Attribute Richard Hollister Excel Discussion (Misc queries) 6 April 20th 07 04:26 PM
Cannot remove read only attribute Colin Gough Excel Discussion (Misc queries) 2 September 27th 06 12:37 AM
Tried changing a file attribute from read only but I get error msg willymoore809 Excel Discussion (Misc queries) 5 June 5th 06 01:25 PM
Read Only attribute disappears Ken G. Excel Discussion (Misc queries) 1 December 2nd 04 12:32 AM


All times are GMT +1. The time now is 04:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"