How to overwrite a file automaticaly

  • Thread starter Thread starter bbnimda
  • Start date Start date
B

bbnimda

Hi all,

I'm using this in outlook script , but if the file exist the system display
a message and ask me if I want to overwrite it

objExcelApp.ActiveWorkbook.SaveAs \\Backup\mybackup.xls"

is there a way to bypass the message and save the file without displaying
the message ?

Tks
 
Application.DisplayAlerts = False
objExcelApp.ActiveWorkbook.SaveAs "\\Backup\mybackup.xls"
Application.DisplayAlerts = True

or

Kill "\\Backup\mybackup.xls"
objExcelApp.ActiveWorkbook.SaveAs "\\Backup\mybackup.xls"


HTH,
JP
 
No it doesn't work :(

"JP" <[email protected]> a écrit dans le message de (e-mail address removed)...
Application.DisplayAlerts = False
objExcelApp.ActiveWorkbook.SaveAs "\\Backup\mybackup.xls"
Application.DisplayAlerts = True

or

Kill "\\Backup\mybackup.xls"
objExcelApp.ActiveWorkbook.SaveAs "\\Backup\mybackup.xls"


HTH,
JP
 
Can you be more specific?

Did you step through the code? If so, what line caused the error? And
what was the error message?

What version of Outlook are you using, and where exactly are you using
the code (class module, userform, outlook form, etc)?


Thx,
JP
 
I tryed the two method above, but It doesn't change anything , I still have
a message asking me If I want to Overwrite the existing file.

Application.DisplayAlerts = False
objExcelApp.ActiveWorkbook.SaveAs "\\Backup\mybackup.xls"
Application.DisplayAlerts = True

and

Kill "\\Backup\mybackup.xls"
objExcelApp.ActiveWorkbook.SaveAs "\\Backup\mybackup.xls"




"JP" <[email protected]> a écrit dans le message de (e-mail address removed)...
Can you be more specific?

Did you step through the code? If so, what line caused the error? And
what was the error message?

What version of Outlook are you using, and where exactly are you using
the code (class module, userform, outlook form, etc)?


Thx,
JP
 
My bad, try this:

objExcelApp.DisplayAlerts = False
objExcelApp.ActiveWorkbook.SaveAs "\\Backup\mybackup.xls"
objExcelApp.DisplayAlerts = True

'Application' is referring to Outlook, so the code should fail, so it
should be 'objExcelApp' because that is the reference to the Excel
application.


HTH,
JP
 
Back
Top