application.alertdisplay - does not work without application.

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I removed application from the second line like this
Code:
 DisplayAlerts = False
but that did not work, excel gave me the warning. Why I need to add Application.
in this case? because with workbooks, I do not need to add Application.
So I can say
Code:
 workbooks.add
instead of
Code:
 application.workbooks.add
but that is not the case with DisplayAlerts. Thank you very much.

Code:
Sub deletesheet()
    Application.DisplayAlerts = False
    Dim x As Integer
    x = InputBox("enter sheet#")
    Workbooks(1).Worksheets(x).Delete
    Application.DisplayAlerts = True
End Sub
 
Last edited:

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
But what is the problem?
To add books there are no warnings.
But to delete if there is warning, to avoid the warning you can use
Application.DisplayAlerts = False
 
Upvote 0
From Microsoft.com

Many of the properties and methods that return the most common user-interface objects, such as the active cell (ActiveCell property), can be used without the Application object qualifier. For example, instead of writing:

Application.ActiveCell.Font.Bold = True
You can write:

ActiveCell.Font.Bold = True
 
Upvote 0
No what I meant, I can not use "Application.DisplayAlerts = False" without typing "Application."
In another words, if I do this line of code, it wont work
Code:
 DisplayAlerts = False

The adding workbook was just an example. Thank you once again

But what is the problem?
To add books there are no warnings.
But to delete if there is warning, to avoid the warning you can use
Application.DisplayAlerts = False
 
Upvote 0
Some properties of the application require the expression: Application. In this case it is necessary to put Application to work.
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,166
Members
448,870
Latest member
max_pedreira

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