I created a CSV file that I want to import into Excel for easier viewing. I'm getting an error on the RED line,
error is
Object Variable or With block variable not set.
I used Excel to create the macro code.
here is my code
DougP
error is
Object Variable or With block variable not set.
I used Excel to create the macro code.
here is my code
Code:
Dim oApp As Excel.Application
Set oApp = CreateObject("Excel.Application")
oApp.Visible = True
[COLOR=red]With oApp.ActiveSheet.QueryTables.Add(Connection:="TEXT;F:\TimeSheet2\OHCPay20080204.csv", Destination:=Range("A1"))[/color]
.Name = "OHCPay20080204"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Set oApp = Nothing
DougP