application.alertdisplay - does not work without application.

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,693
Office Version
  1. 365
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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,619
Office Version
  1. 2007
Platform
  1. Windows
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
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
14,046
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
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
 

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,693
Office Version
  1. 365
Platform
  1. Windows
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
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,619
Office Version
  1. 2007
Platform
  1. Windows
Some properties of the application require the expression: Application. In this case it is necessary to put Application to work.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,467
Messages
5,636,456
Members
416,919
Latest member
twc2c

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
Top