Hi All
Really hope you can help me with this one...its killing me!.
In advance...thank you for helping ;-)
I'm using Office 2010, and i have made a connection to an external database.
When i extract the data, i dont want the headers/"field names" from the Access database table to be exported to my Excel Woorkbook/sheet, just the data form the rows in the table.
I have tried to import with headers/"field names", and hide them using:
ActiveSheet.ListObjects("MyListName").ShowHeaders = False
Then delete the row. Ant put ".RefreshStyle = xlOverwriteCells" in the Query.
But this method leaves "traces" of the row, where the headers/"field names", used to be.
This results in "overlap" errors when i refresh the workbook.
Here is the code that works just fine...besides the headers/"field names" :-)
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"OLEDB;Provider=SQLOLEDB.1;Data Source=ly-db-01;Initial Catalog=QALY;Integrated Security=SSPI" _
, Destination:=Range("MyRange")).QueryTable
.CommandType = xlCmdSql
.CommandText = "SELECT XXX_Nr, Init, Date, XXX_Closed_Date FROM Q_XXX_List WHERE XXX_Nr = " & MyListValueToGetDataFromRow
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = False
.SourceConnectionFile = _
"C:\Documents and Settings\MyPath\MyDataBase.adp"
.ListObject.DisplayName = "MyListName"
.Refresh BackgroundQuery:=False
End With
Bookmarks