HI, i just want Excel to stop asking me if i want to replace a file...

the code look like this:

Dim oXL As Object        
Dim oBook As Object      
Dim oSheet As Object    
Set oXL = New Excel.Application
 Set oBook = oXL.Workbooks.Open("PATH")
 Set oSheet = oBook.Worksheets.Item(1)
oSheet.Cells(x,y) = bla, bla, bla
oBook.SaveAs App.Path & "\" & FileName & ".xls" ' HERE IS THE PROBLEM

is there any flag that indicates, from VB, to stop asking if i want to replace the file?


Who is Participating?
lunchbyteConnect With a Mentor Commented:
if dir(oBook.SaveAs App.Path & "\" & FileName & ".xls") <> "" then kill oBook.SaveAs App.Path & "\" & FileName & ".xls"
patobrownAuthor Commented:
Thanks,  it works, but i found in the Intenet:

oXL.DisplayAlerts = False
oBook.SaveAs App.Path & "\" & nombrelocal & ".xls"
oXL.DisplayAlerts = True

it works too.

thanks anyway.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.