代表從 PowerPivot 模型傳回的資料所建置的工作表表格。
範例
下列範例程式碼會連線到資料來源來建立 PowerPivot 查詢資料表。
Sub CreateTable()
Dim objWBConnection As WorkbookConnection
Dim objWorksheet As Worksheet
Dim objTable As TableObject 'This is the new Table object
Set objWorksheet = ActiveWorkbook.Worksheets("Sheet1")
'Create a WorkbookConnection to the external data source first.
Set objWBConnection = ActiveWorkbook.Connections.Add2( _
"Cubes3 AdventureWorksDW DimEmployee1", "", Array( _
"OLEDB;Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=AdventureWorksDW;Data Source=MyServer;Use " _
, _
"Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=MYWORKSTATION;Use Encryption for Data=False;Tag with co" _
, "lumn collation when possible=False"), Array( _
"""AdventureWorksDW"".""dbo"".""DimEmployee"""), 3, True)
'Create a new table connected to the model.
Set objTable = objWorksheet.ListObjects.Add(SourceType:=xlSrcModel, Source:=objWBConnection, Destination:=Range("$A$1")).TableObject
objTable.Refresh
End Sub
方法
屬性
- AdjustColumnWidth
- 應用程式
- Creator
- Destination
- EnableEditing
- EnableRefresh
- FetchedRowOverflow
- ListObject
- Parent
- PreserveColumnInfo
- PreserveFormatting
- RefreshStyle
- ResultRange
- RowNumbers
- WorkbookConnection
另請參閱
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。