Error when trying to use QueryTables.Add
I´ve got some problems when I try to use QueryTables.Add on a sheet tha
I previously has created with : Worksheets.Add(After:=Worksheets(Worksheets.Count) ) I get the error Run-Time error '5' I have tried both: With ActiveSheet.QueryTables.Add........... and With Sheets(MyBacklogname).QueryTables.Add...... Code: MyBacklogname = "Outfile_B" & Sheets("Parametrar").Cells(7, 2).Value "_backlog" Set oSheet = Worksheets.Add(After:=Worksheets(Worksheets.Count) ) With oSheet .Name = MyBacklogname End With Sheets(MyBacklogname).Activate Sheets(MyBacklogname).Select MyConnection = "TEXT;" & ActiveWorkbook.Path & "\" & MyBacklognam & ".txt" With ActiveSheet.QueryTables.Add(Connection:=MyConnecti on Destination:=Range("D2")) .Name = "Outfile_Pplan" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .TextFilePromptOnRefresh = False .TextFilePlatform = xlWindows .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = False .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = False '.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1 1) .Refresh BackgroundQuery:=False End With \Someone help me : -- Message posted from http://www.ExcelForum.com |
All times are GMT +1. The time now is 11:40 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com