ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Saving in Shared mode (https://www.excelbanter.com/excel-programming/427539-saving-shared-mode.html)

Stephen sjw_ost

Saving in Shared mode
 
I have an Excel spreadsheet that is being used in a SharedWorkbook state. I
have placed buttons on the tabs for my users to save the file instead of
using the save button on the Excel Menu Bar. I do this so the button can
update the time on the worksheet(s) to indicate what time the save occured.
The problem I am having is when 2 or more users try to save at the same
time, with or without using the button(s). The first user will be able to
save just fine but anyone else saving at that moment will get an error that
the file is locked and to try again later.

How can I make a loop that will detect if the file is busy and loop until
the file is available again, once available, perform the save?

Just off the top of my head, something like;

Do
If application locked "need help here" then
loop until application unlocked "need help here"
Else
Application.ActiveWorkBook.Save
End If

I hope this question makes sense.
Any help with this is greatly appreciated.
--
Stephen

Stephen sjw_ost

Saving in Shared mode
 
I figured out my own answer.

Do
On Error Resume Next
ActiveWorkbook.Save
Loop until ActiveWorkbook.saved = True

Thank you.
--
Stephen


"Stephen sjw_ost" wrote:

I have an Excel spreadsheet that is being used in a SharedWorkbook state. I
have placed buttons on the tabs for my users to save the file instead of
using the save button on the Excel Menu Bar. I do this so the button can
update the time on the worksheet(s) to indicate what time the save occured.
The problem I am having is when 2 or more users try to save at the same
time, with or without using the button(s). The first user will be able to
save just fine but anyone else saving at that moment will get an error that
the file is locked and to try again later.

How can I make a loop that will detect if the file is busy and loop until
the file is available again, once available, perform the save?

Just off the top of my head, something like;

Do
If application locked "need help here" then
loop until application unlocked "need help here"
Else
Application.ActiveWorkBook.Save
End If

I hope this question makes sense.
Any help with this is greatly appreciated.
--
Stephen



All times are GMT +1. The time now is 04:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com