Changing only source file of pre-existing text import QueryTable?

T

Tom Ogilvy

right click on the query in the worksheet and choose to edit the query.

Turn the macro recorder on while you do it manually if you are looking for
code.
 
E

EBrowne

Hey, thanks for the reply. My long post got cut, it seems. I've written a
very long, involved macro that imports data from hundreds of data files.
Unfortunately, I've got multiple formats, including fixed width columns, and
I need to excerp various numbers of rows and columns. Unfortunately, the top
row is not always the labels row, and the labels often have spaces in them,
so using spaces as a delimiter in fixed column formats screws up the labels.

So instead of hard-wiring the data import into my code, I would like to
change the queries in the template, and then simply change the data file
source with the code.

However, when I change the .Connection property, it blanks out all the other
settings
in the querytable definitions. I've watched them go blank in the locals
window. And when I change the .SourceDataFile, it has no effect on the
..Connection property, so the same default file keeps being imported.

Any ideas?
 
T

Tom Ogilvy

I can't say about your other properties, but you have to change the
connection property and the sql property.

I'm using Excel 97, so I don't have a sourcedatafile property.

Maybe you just want to record creating your querytable, then generalize the
code so you can feed different arguments to it. Delete the table between
each creation. That will record setting the properties.
 
Top