correction

N

nowfal

Hi all,
I have the following code
Range("A5,A4").ClearContents
Range("A4").Select
Windows("MICR.xls").Activate
Range("N2").Select
Windows("MICR PRINT.xls").Activate
ActiveCell.FormulaR1C1 = "=MICR.xls!R2C14"
Range("B4").Select
Sheets("DA").Select
Range("A9,A10,A11").ClearContents
Range("A10").Formula = "=Spellnumber(A9)"
Range("A9").Select
Windows("MICR PRINT.xls").Activate
ActiveCell.FormulaR1C1 = "=MICR.xls!R2C15"
Range("A2").Select
Sheets("SA").Select
Range("A9,A10,A11").ClearContents
Range("A10").FormulaR1C1 = "=SPELLNUMBER(R[-1]C,""INR"")"
Range("A9").Select
Windows("MICR PRINT.xls").Activate
ActiveCell.FormulaR1C1 = "=MICR.xls!R2C15"
Range("A2").Select
Sheets("MICRI").Select
Range("A1").Select
ActiveWorkbook.Save
Windows("MICR.xls").Activate
ActiveWorkbook.Close

In this final 2 lines i wanted a change instead of
ActiveWorkbook.close
i wanted to delete the MICR.xls file which is in C:My Document, i tried
Delete
Any other alternate for this
with regards
nowfal
 
N

nowfal

Hi Ardus Petus,
I have tried the "kill" , but the file is still there in my document. I
wanted to delete the file micr.xls for good.
thx and regards
nowfal
 
B

BrianH

"Delete" is a VBA Method applied to various Objects within Excel - it will
not delete a file from the disk.

"Kill" as per Ardus's post should work. It is a VB command dealing with the
computer's file system. But I think if you try to replace
ActiveWorkbook.Close with Kill, nothing will happen because the file is still
open, and so the operating system won't let it be deleted from the disk. You
must first Close the file, and then Kill it.

(You'll get a "Cannot delete . . ." error message if you try to delete an
open file in Windows Explorer, but if my memory serves me correctly, Kill
gives no warnings, it just doesn't do anything if it's an illegal command.)

BrianH
 
N

nowfal

Hi Brian,
You are absolutely right. I have tried by your way, then the
file got deleted from the my document itself. Thanks once again both of
you.
with regards
NOWFAL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

joining macro 1
Select until blank row 8
Filename Problem In a Macro 4
code question 2
Macro to generate FileName of the source file 1
Help again!!! 1
Excel Macro Help 4
Macro to save a workbook 1

Top