ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   avoiding dialog boxes in macros (https://www.excelbanter.com/excel-programming/279256-avoiding-dialog-boxes-macros.html)

Bruce Bowler

avoiding dialog boxes in macros
 
I have a script that I'm working on that, among other things may try and
write a file that already exist. Currently, it pops up a dialog box and
stalls the process. I'd like to not have the dialog boxes come up, but
rather simply overwrite the file. What option(s) do I need to specify to
accomplish that goal?

Bruce

--
+-------------------+---------------------------------------------------+
Bruce Bowler | When your illusions are gone you have ceased to
1.207.633.9600 | live. - Anonymous
|
+-------------------+---------------------------------------------------+


[email protected]

avoiding dialog boxes in macros
 
Application.DisplayAlerts = False
' Your code here to overwrite file.
Application.DisplayAlerts = True

HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------

I have a script that I'm working on that, among other things may try and
write a file that already exist. Currently, it pops up a dialog box and
stalls the process. I'd like to not have the dialog boxes come up, but
rather simply overwrite the file. What option(s) do I need to specify to
accomplish that goal?

Bruce



Tom Ogilvy

avoiding dialog boxes in macros
 
if it is a workbook

Application.DisplayAlerts = False
thisworkbook.SaveAs . . .
Application.DisplayAlerts = True

An alternative is

fName = "C:\Whatever.xls"
On error resume next
kill fname
On Error goto 0
Thisworkbooks.SaveAs fName

--
Regards,
Tom Ogilvy

"Bruce Bowler" wrote in message
...
I have a script that I'm working on that, among other things may try and
write a file that already exist. Currently, it pops up a dialog box and
stalls the process. I'd like to not have the dialog boxes come up, but
rather simply overwrite the file. What option(s) do I need to specify to
accomplish that goal?

Bruce

--
+-------------------+---------------------------------------------------+
Bruce Bowler | When your illusions are gone you have ceased to
1.207.633.9600 | live. - Anonymous
|
+-------------------+---------------------------------------------------+





All times are GMT +1. The time now is 05:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com