We have a custom class, cusExcel, that wraps an Excel object. When we call various methods we set (reset) DisplayAlerts because it does set itself to .T. at times. At least with Office 2007.
CreateExcel()
LOCAL RetVal
IF TYPE('This.oExcel') # 'O' AND NOT ISNULL(This.oExcel)
This.oExcel = CREATEOBJECT('Excel.Application')
ENDIF
IF TYPE("This.oExcel") = 'O' AND NOT ISNULL(This.oExcel)
RetVal = .T.
This.oExcel.DisplayAlerts = .F.
ENDIF
RETURN m.RetVal
Hide()
This.oExcel.Visible = .F.
This.oExcel.DisplayAlerts = .F.
AsSave()
...
IF This.oExcel.Visible
This.oExcel.DisplayAlerts = This.DisplayAlerts
ELSE
This.oExcel.DisplayAlerts = .F.
ENDIF
....
Close()
IF .oExcel.Visible
.oExcel.DisplayAlerts = .DisplayAlerts
ELSE
.DisplayAlerts = .F. && DisplayAlerts can get reset.
ENDIF
....
Save()
....
IF .Visible
.DisplayAlerts = This.DisplayAlerts
ELSE
.DisplayAlerts = .F. && DisplayAlerts can get reset.
ENDIF
...
This seems to control the DisplayAlerts fine.
Charlie