Shortly after posting the first message on this topic I had cause to use it in a real life situation. All was fine until a cell in my text field had more than 255 (?) characters. It broke the solution!
I haven't had time to fully investigate exact limits in all of this but I think the Excel ODBC driver will only accept up to about 255 characters in a "Text" field. If the driver comes across more than 255 characters it interprets it as a "Memo" type content (up to 32k characters?) and the attempt to query fails at the record that contains the offending data. How to work around?
Using the IMEX=2 approach from the previous article, firstly, I appended 256 spaces into the first rows of the field that needs to be "Memo". This was to force the majority type interpretation of this field to be "Memo". Once this had been done I discovered that the query no longer failed but it only returned the first 253 characters of the "Memo" field. Why I'm getting 253 I'm not sure but it seems this is a limitation of the Excel ODBC driver when dealing with "Memo" fields. However, I discovered that if I constructed additional calculated fields in my SQL I could bring back the entire contents of the "Memo" field in 253 character chunks. The SQL select clause entries look as follows:
''+F1 as [Memo Field],
mid(''+F1,254,253) as [Memo Field 2],
mid(''+F1,507,253) as [Memo Field 3], ... and so on.
I'd be really interested if anyone is able to put some better flesh on these bones.