Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default The Shifty Lie of a Query Table

I am trying to leverage a query tables refresh ability with a simple txt
file import. I am having a problem with the Query table shifting columns over
when the query table code is run. I need to have the query table to simply
€˜paste into worksheet as if I selected Cells(1,1) and pasted them in. At
first I thought there should be a parameter or option to do this but I have
not found one. Does anyone know how to do this?

Private Sub OpenFile( cflaSpec As Range)
Dim FileDir As QueryTable
Dim DirPath As String
'Initialize
DirPath = "\\gershwin\majorprojects\CFLA\CFLAReportName & ".txt"
Set ProperPallet = ActiveWorkbook.Worksheets.Add
Set FileDir = ProperPallet.QueryTables.Add( _
Connection:="TEXT;" & DirPath, _
Destination:=wksht.Cells(1, 1) _
)
With FileDir
.TextFileParseType = xlDelimited
.TextFileOtherDelimiter = "|"
.Refresh
End With
Wksht.name= UCase(cflaSpec)
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default The Shifty Lie of a Query Table

Add this line just before the Refresh line in your code:

..RefreshStyle = xlOverwriteCells

Does that help?

***********
Regards,
Ron

XL2002, WinXP-Pro


"DynamiteSkippy" wrote:

I am trying to leverage a query tables refresh ability with a simple txt
file import. I am having a problem with the Query table shifting columns over
when the query table code is run. I need to have the query table to simply
€˜paste into worksheet as if I selected Cells(1,1) and pasted them in. At
first I thought there should be a parameter or option to do this but I have
not found one. Does anyone know how to do this?

Private Sub OpenFile( cflaSpec As Range)
Dim FileDir As QueryTable
Dim DirPath As String
'Initialize
DirPath = "\\gershwin\majorprojects\CFLA\CFLAReportName & ".txt"
Set ProperPallet = ActiveWorkbook.Worksheets.Add
Set FileDir = ProperPallet.QueryTables.Add( _
Connection:="TEXT;" & DirPath, _
Destination:=wksht.Cells(1, 1) _
)
With FileDir
.TextFileParseType = xlDelimited
.TextFileOtherDelimiter = "|"
.Refresh
End With
Wksht.name= UCase(cflaSpec)
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default The Shifty Lie of a Query Table

Works Perfectly... Thanks Ron

-D

"Ron Coderre" wrote:

Add this line just before the Refresh line in your code:

.RefreshStyle = xlOverwriteCells

Does that help?

***********
Regards,
Ron

XL2002, WinXP-Pro


"DynamiteSkippy" wrote:

I am trying to leverage a query tables refresh ability with a simple txt
file import. I am having a problem with the Query table shifting columns over
when the query table code is run. I need to have the query table to simply
€˜paste into worksheet as if I selected Cells(1,1) and pasted them in. At
first I thought there should be a parameter or option to do this but I have
not found one. Does anyone know how to do this?

Private Sub OpenFile( cflaSpec As Range)
Dim FileDir As QueryTable
Dim DirPath As String
'Initialize
DirPath = "\\gershwin\majorprojects\CFLA\CFLAReportName & ".txt"
Set ProperPallet = ActiveWorkbook.Worksheets.Add
Set FileDir = ProperPallet.QueryTables.Add( _
Connection:="TEXT;" & DirPath, _
Destination:=wksht.Cells(1, 1) _
)
With FileDir
.TextFileParseType = xlDelimited
.TextFileOtherDelimiter = "|"
.Refresh
End With
Wksht.name= UCase(cflaSpec)
End Sub

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
a query for pivot table Arvind Excel Discussion (Misc queries) 1 January 25th 08 02:32 PM
Pivot Table Query Louise Excel Discussion (Misc queries) 1 June 1st 06 11:52 PM
VB way to remove the query from a Query Table? Toby Erkson[_3_] Excel Programming 4 October 29th 04 03:16 PM
How tp query a spreadsheet table? Henrik Ekeblad Excel Programming 0 April 27th 04 09:45 AM
Linking a table in Access to a table in Excel using MS Query Diana[_5_] Excel Programming 1 January 16th 04 09:43 PM


All times are GMT +1. The time now is 04:29 PM.

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"