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
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
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.
 
Upvote 0

Forum statistics

Threads
1,215,011
Messages
6,122,677
Members
449,092
Latest member
tayo4dgacorbanget

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top