2
votes

Before setting Application.DisplayAlerts = FalseIt gets set to falseYet it still gives me the save as!

For those who don't like images:

  Close logFile
  Application.DisplayAlerts = False 
  If WasOpened2 Then Workbooks(FilenameNoPath(FoundFiles(i))).Close False 
  Application.DisplayAlerts = True

Application.DisplayAlerts = False should suppress any and all alerts from excel. Furthermore, I'm led to believe that passing False to .Close should automatically not save changes on the workbook. Yet I still get a prompt. Any ideas?

1
Also, feel free to lol at the dumb comments in there, they aren't mine.James
Is FilenameNoPath an array or Function? I would assume a Function.Paul McLain
@PaulR It's a function, it does not close the file. It only returns the filename without a path.James
And there's nothing in that function that is changing .DisplayAlerts = True? That was the first thought I had.Paul McLain
@PaulR I resolved the issue, thanks for your help.James

1 Answers

3
votes

I had the inkling that another Excel add-in that was running alongside could be causing the issue. Coworker suggested to wrap with code to suppress events. This worked:

  Application.EnableEvents = False
  Application.DisplayAlerts = False
  If WasOpened2 Then Workbooks(FilenameNoPath(FoundFiles(i))).Close False 
  Application.DisplayAlerts = True
  Application.EnableEvents = True