Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default QueryTable Null Import Quirk / Problem

Hi all,

I am using a QueryTable to import data from multiple CSVs (I have used /
tried many other procedures ie OpenText - but the CSVs vary in format
unpredictably - and other import routines resulted in text OR date parsing
with problems).
This has been working well until I noticed an oddity (at least with my
code): if the specified CSV is empty, the QT procedure runs without
exception. However, successive calls to the routine do NOT import any data -
it is as if the QT routine is 'stuck'. If I skip processing the empty file,
all successive CSVs import OK.
I suspect that the QT isn't being deleted / released - or maybe something
else...

I have tried adding code to delete all QTs from the import sheet to no avail.

'copyto' is a worksheet, 'FName' is CSV full file path (string)

With copyto.QueryTables.Add(Connection:="TEXT;" & FName,
Destination:=copyto.Range("A1"))
.AdjustColumnWidth = True
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.Refresh BackgroundQuery:=False
.Delete
End With

I could use FileLen to check CSV size and skip empty files if there is no
'fault' in the code etc... I'd rather not read the CSVs in line by line (or
as a string that I split on vbCrlf) etc...

Guidance greatly appreciated as ever.

Mike
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import data using QueryTable somehow change sheet cells references JackCali Excel Programming 2 April 6th 07 05:34 PM
Excel Import to Access null issue [email protected][_2_] Excel Programming 3 September 29th 06 12:39 PM
QueryTable date problem Tom Excel Programming 0 May 3rd 06 02:43 PM
Changing only source file of pre-existing text import QueryTable? EBrowne Excel Programming 3 August 23rd 04 03:31 AM
Using Querytable.add to import data from a closed workbook Markus Stolle[_5_] Excel Programming 8 August 3rd 04 08:51 PM


All times are GMT +1. The time now is 06:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"