我是将英文的Northwind.mdb数据库放到C:\录制的宏:
Sub Macro4()
With ActiveWorkbook.PivotCaches.Add(SourceType:=xlExternal)
.Connection = _
"ODBC;DSN=MS Access Database;DBQ=C:\Northwind.mdb;DefaultDir=C:;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;"
.CommandType = xlCmdSql
.CommandText = Array( _
"SELECT `Alphabetical List of Products`.ProductID, `Alphabetical List of Products`.ProductName, `Alphabetical List of Products`.SupplierID, `Alphabetical List of Products`.CategoryID, `Alphabetical Lis" _
, _
"t of Products`.QuantityPerUnit, `Alphabetical List of Products`.UnitPrice, `Alphabetical List of Products`.UnitsInStock, `Alphabetical List of Products`.UnitsOnOrder, `Alphabetical List of Products`.R" _
, _
"eorderLevel, `Alphabetical List of Products`.Discontinued, `Alphabetical List of Products`.CategoryName" & Chr(13) & "" & Chr(10) & "FROM `C:\Northwind`.`Alphabetical List of Products` `Alphabetical List of Products`" _
)
.CreatePivotTable TableDestination:="[xlsExplorerDemo.xls]第二页!R3C2", _
TableName:="数据透视表3", DefaultVersion:=xlPivotTableVersion10
End With
ActiveWorkbook.ShowPivotTableFieldList = True
End Sub
u7fdlEWm.rar
(43.07 KB, 下载次数: 60)
[此贴子已经被作者于2004-6-25 15:16:54编辑过] |