Solved

EXCEL STUFF

Posted on 2006-06-16
2
177 Views
Last Modified: 2010-04-30
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?

thanks.

0
Comment
Question by:patobrown
2 Comments
 
LVL 5

Accepted Solution

by:
lunchbyte earned 125 total points
Comment Utility
if dir(oBook.SaveAs App.Path & "\" & FileName & ".xls") <> "" then kill oBook.SaveAs App.Path & "\" & FileName & ".xls"
0
 

Author Comment

by:patobrown
Comment Utility
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.

0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now