Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

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
QueryTables Error Sharlene England Excel Programming 3 August 19th 04 10:36 PM
QueryTables Error GJones Excel Programming 0 April 27th 04 02:35 PM
Using Add Method of QueryTables gives error Shilps Excel Programming 1 April 22nd 04 03:49 PM
With ActiveSheet.QueryTables.Add [email protected] Excel Programming 4 January 6th 04 04:58 PM


All times are GMT +1. The time now is 05:33 AM.

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

About Us

"It's about Microsoft Excel"