ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Query fails, requiring excel to be closed and restarted (https://www.excelbanter.com/excel-programming/392017-query-fails-requiring-excel-closed-restarted.html)

[email protected][_2_]

Query fails, requiring excel to be closed and restarted
 
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.


[email protected][_2_]

Query fails, requiring excel to be closed and restarted
 
Quick follow up: my query does not include

..SaveData = True

Thanks.



All times are GMT +1. The time now is 07:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com