macro that opens file named in cell doesnt work

I

Illuminati

I wrote a macro that should open file with the name specified in cell
B8. It worked well yesterday but today I opened the file and the macro
doesnt work at all.

Could anyone tell whats wrong with the code.

Here it is the code:

Sub Import()

Sheets("Instruction").Select
Range("B8").Select
filetext = Selection.Value & ".xls"
directory = ".\"
Workbooks.Open directory & filetext

End Sub
 
I

Illuminati

Try setting directory to the full path.

But I need this macro to open file from folder that the file with
macro is.
Btw, I have tried to put the name of the folder but it still doesn't
work.
It works when I put the exact path of the file with the name (not
reffering to the cell).

Please help, I have tried to modify the code and put sth like this:
Workbooks.Open Filename:= _
".\" & Range("B8").Value & ".xls"
But the error is still the same:
run-time error '1004'
 

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