MrExcel Publishing
Your One Stop for Excel Tips & Solutions

how do i eliminate message boxes in my macro run


Posted by robert on September 10, 2001 11:25 AM


I have some pre recorded macros that I run but half way in I close a .txt file I opened in excel. I always get a message box asking if I want to save changes. My answer is always NO and I want that to happen without being asked every time. How can I do it. Thanks
~robert


Posted by faster on September 10, 2001 11:37 AM

this may do it

Application.DisplayAlerts = False
'close file
Application.DisplayAlerts = True

Posted by faster on September 10, 2001 11:38 AM

I tried to post this once, but it didn't show up.

Application.DisplayAlerts = False
'close file
Application.DisplayAlerts = True

Posted by Dax on September 10, 2001 11:46 AM

Not sure if it's what you want but how about this?

Sub CloseATextFile()
Dim sFileName As String
sFileName = "Book1.txt"
Workbooks(sFileName).Close False
End Sub


It will close the specified file without prompting for Save Changes.

Regards,
Dax.