Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I added a test for file size in the code below Sub testQuery() Set fs = CreateObject("Scripting.FileSystemObject") On Error GoTo errorHandler Dim newSheet As Worksheet Dim Filename As String Filename = "file.CSV" Set f = fs.getfile(Filename) If f.Size = 0 Then Exit Sub Set newSheet = Sheets.Add newSheet.Name = "test" With newSheet.QueryTables.Add(Connection:="TEXT;" & Filename, _ Destination:=newSheet.Range("A1")) Name = "test" FieldNames = False RowNumbers = False FillAdjacentFormulas = False PreserveFormatting = True RefreshStyle = xlInsertDeleteCells SavePassword = False SaveData = True AdjustColumnWidth = True RefreshPeriod = 0 TextFilePromptOnRefresh = False TextFileStartRow = 1 TextFileParseType = xlDelimited TextFileTextQualifier = xlTextQualifierDoubleQuote TextFileConsecutiveDelimiter = False TextFileTabDelimiter = False TextFileSemicolonDelimiter = False TextFileCommaDelimiter = True TextFileSpaceDelimiter = False TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1) Refresh BackgroundQuery:=False End With Exit Sub If newSheet.Range("A1").Value2 = "" Then MsgBox ("Cell is blank") newSheet.Delete errorHandler: MsgBox prompt:=Err.Description, Title:=Err.Number Exit Sub End Sub -- joel ------------------------------------------------------------------------ joel's Profile: 229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=160662 Microsoft Office Help |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Imported text file to begin from the first empty cell | Excel Programming | |||
Reset Delimiter when opening text file | Excel Programming | |||
Saving to text file - tabs from empty cells ignored | Excel Programming | |||
how to reset data entry cells to 0 or empty | Excel Programming | |||
Changing only source file of pre-existing text import QueryTable? | Excel Programming |