Share via

MACRO: Sharing Violations

Anonymous
2011-04-18T13:44:56+00:00

hi, I have a script that found included in my 'thisworkbook' portion of excel.  I have Sharing Violation errors that do a couple of things.

I just tried to save a copy to another folder and rename it.  it said the file was being used by someone else, as a 'copy', and would not let me rename file.  a minute later I have access.  (copy was only 20 seconds old).

it also will sometimes go read-only as a sharing violation while editing,  if I don't catch that,  I might lose a couple of hours of work if I don't save to a new file name.

the following script I found does not seem to correct that problem.  is there a solution?  thanks

would rather lock file out from all other access / sharing.

Option Explicit

Private Sub Workbook_Open()

    If ActiveWorkbook.MultiUserEditing Then

        Application.DisplayAlerts = False

        ActiveWorkbook.ExclusiveAccess

        Application.DisplayAlerts = True

        MsgBox "Workbook Now Exclusive"

    End If

If ActiveWorkbook.Name = "symbols.xls" Then

If Range("A1").Value = "." Then

    Application.Calculate

    End If

End If

End Sub

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2011-04-18T22:55:54+00:00

It sounds rather like a problem that can be caused by an over-zealous virus checker.

See if you can turn off your virus-checker's checking of Office documents when you save them, and if so, does that solve the problem?

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2011-04-19T01:14:35+00:00

    thanks, i'll check that out.  will still look for way to secure files from external effects.

    Was this answer helpful?

    0 comments No comments