Query fails, requiring excel to be closed and restarted

N

no.reply7

I am using following query:

With ActiveSheet.QueryTables.Add(Connection:= "TEXT:my_query",
Destination:=ActiveCell)
.SaveData = True
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 9, 9, 9, 9, 9, 1)
.Refresh BackgroundQuery:=False

It works fine unless the query fails. At that point, when running a
subsequent valid query, I get the following error message:

Microsoft Office Excel cannot access the file etc...
There are several possible reasons:
The file name or path does not exist
The file is being used by another program
The workbook you are trying to same has the same name as a currently
open workbook

I have to to shut excel down to make the query work again. If I only
close and reopen, the query still fails.

I've search for the problem but found not workable solution.

Any thoughts?

Thanks.
 

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