Error Opening a File

M

Mili

Hi,

I am trying to open a existing text file to write some
text,but the Existing Text file is already open.
So I can't write anything using VBA Macro for Excel 2000.

I am getting error while Opening the Text file.

Is it possible for any one to guide how to handle this
Error ??
I am using following code.
here fileName is already open in some other applicaiton.

Open fileName For Output Access Write As #fileNumber

How to handle this Error . I want to display an error
message saying that The file is already open ..

Thanks

Mili.
 
E

Earl Kiosterud

Mili,

On Error GoTo errorhandler:
Open "test.txt" For Output As #1

errorhandler:
MsgBox "Error " & Err.Number & " " & Err.Description

Or you can examine Err for a value of 55, 70, etc.
If Err = 70 then MsgBox "Hey, permission is denied. The file's probably
aleady open somewhere else. Or something. This process is toast."
 

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

Top