QueryTable Supress Headers?

P

pdxJaxon

I am programatically inserting a querytable into my wkSht and need the
ability to suppress the headers when inserting the table.
I'm not able to get the QueryTable.FieldNames = false statement to work...
Adding the FieldNames=false throws a generic COM HResult.

this is VERY important.....!

code below and Thanks in Advance

'****************************************************

'Create the object list
objList =
MySheet.ListObjects.Add(SourceType:=Excel.XlListObjectSourceType.xlSrcExternal, _

XlListObjectHasHeaders:=Excel.XlYesNoGuess.xlGuess, _
Source:=src, _
Destination:=myRange).QueryTable
'append properties to objList
With objList
.CommandType = Excel.XlCmdType.xlCmdSql
.CommandText = "select Sum(CYA1) As CYA1 from Fact_GLData"
.RowNumbers = False
.FieldNames=False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = Excel.XlCellInsertionMode.xlOverwriteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 60
.PreserveColumnInfo = False
.ListObject.DisplayName = "Table_Fact_GLData"
.Refresh(BackgroundQuery:=False)
.EnableEditing = True
.EnableRefresh = True
.SaveData = True
End With



'*****************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top