Help in turning Alerts & Prompts off (not as easy as you think!)

jbugman

New Member
Joined
Sep 3, 2009
Messages
4
Hello,

Turning prompts/alerts off and on in excel is easy with:
Code:
Application.DisplayAlerts = False 
' Your code
Application.DisplayAlerts = True
However, I am working in a shared workbook. When I want to unshare the workbook, i dont want the prompt "am i sure" bit etc.

Adding the bit above, it doesnt work, any ideas, i really need this to work without user prompt (I can get it to share without it lol)

Code:
Sub unshareme()

Application.DisplayAlerts = False '

If ActiveWorkbook.MultiUserEditing Then
    ActiveWorkbook.ExclusiveAccess

    End If
Application.DisplayAlerts = True 
End Sub
Many thanks for this
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
42,309
Office Version
365
Platform
Windows
However, I am working in a shared workbook. When I want to unshare the workbook, i dont want the prompt "am i sure" bit etc.
Code:
Sub unshareme()

Application.DisplayAlerts = False '

If ActiveWorkbook.MultiUserEditing Then
    ActiveWorkbook.ExclusiveAccess

    End If
Application.DisplayAlerts = True 
End Sub
Many thanks for this
Welcome to the MrExcel board!

That code seems to work for me. I had the shared workbook open on two machines (Excel 2002 and Excel 2007) and ran the code without receiving any warning/alert. The result was an unshared workbook on the machine I ran the code on and the other machine now locked out of the workbook.

Of course, any changes but not saved by the other user(s) will be lost.
 

Forum statistics

Threads
1,082,478
Messages
5,365,789
Members
400,851
Latest member
FrankNStein

Some videos you may like

This Week's Hot Topics

Top