Replacing Excel Files

partham

Active member
Joined
Dec 27, 2005
Messages
41
Location
Kolkata, India
Programming Experience
10+
Dear Sir,

I have a program which creates Excel files. I am faced with a problem that when this program tries to create a file, if any file by that does not exist, everything works fine. However, if a file by that name exists, it pops up a dialog box ask for whether the file should be overwritten or not. How can I avoid this dialog box and force the file to be overwritten?

Regards,
 
you could check if each file exists before creating it, if it does exist then delete it, if not then create the excel file normally
 
Dear Sir,

What about the case where the file is readonly and Windows again throws a dialog seeking confirmation for the deletion to be allowed.

Along the same lines, how can I test whether the user has rights to be able to overwrite or delete or create files?

Regards,
 
what i meant was:

If File.Exist(filepath) = True Then File.Delete(filepath)
'Create the excel file here

if the file is readonly, it wont matter, it gets deleted

if the user doesnt have permission to write files, then it's a problem
 
hi,
which method r u using to create ur excel file. that is, if u r using excel object to save ur file, then u can use the following

App.DisplayAlerts =
False
WBook.SaveAs(Filename)

ur declaration could be some thing like that,

Dim App As New Excel.Application
Dim WBook as Excel.WorkBook
WBook = App.WorkBooks.Add


 
Back
Top