心急如焚,求救,宏应用??? ( 积分: 100 )

  • 主题发起人 主题发起人 aiHis
  • 开始时间 开始时间
A

aiHis

Unregistered / Unconfirmed
GUEST, unregistred user!
我在Excel中录制了如下宏:
怎么通过Delphi来调用!!!

等待!!!


With ActiveWorkbook.PivotCaches.Add(SourceType:=xlExternal)
.Connection = _
"ODBC;DRIVER=SQL Server;SERVER=NHIS-CENTER;UID=sa;PWD=1;APP=Microsoft? Query;WSID=NHIS-CENTER;DATABASE=PJX"
.CommandType = xlCmdSql
.CommandText = Array( _
"SELECT mzfp.CZY, mzfp.KDKS, mzfp.ZXKS, Sum(mzfp.JE)" & Chr(13) & "" & Chr(10) & "FROM PJX.dbo.mzfp mzfp" & Chr(13) & "" & Chr(10) & "GROUP BY mzfp.CZY, mzfp.KDKS, mzfp.ZXKS" & Chr(13) & "" & Chr(10) & "ORDER BY mzfp.CZY, mzfp.KDKS, mzfp.ZXKS" _
)
.CreatePivotTable TableDestination:=Range("A1"), TableName:="数据透视表1"
End With
ActiveSheet.PivotTables("数据透视表1").SmallGrid = False
ActiveSheet.PivotTables("数据透视表1").AddFields RowFields:=Array("KDKS", "ZXKS"), _
ColumnFields:="CZY"
ActiveSheet.PivotTables("数据透视表1").PivotFields("Expr").Orientation = xlDataField
ActiveWindow.SelectedSheets.PrintPreview

若做过Excel数据透视表的同志最好能发个Email这些:lz_zzd@163.com,另外再加分。。。。
 
我在Excel中录制了如下宏:
怎么通过Delphi来调用!!!

等待!!!


With ActiveWorkbook.PivotCaches.Add(SourceType:=xlExternal)
.Connection = _
"ODBC;DRIVER=SQL Server;SERVER=NHIS-CENTER;UID=sa;PWD=1;APP=Microsoft? Query;WSID=NHIS-CENTER;DATABASE=PJX"
.CommandType = xlCmdSql
.CommandText = Array( _
"SELECT mzfp.CZY, mzfp.KDKS, mzfp.ZXKS, Sum(mzfp.JE)" & Chr(13) & "" & Chr(10) & "FROM PJX.dbo.mzfp mzfp" & Chr(13) & "" & Chr(10) & "GROUP BY mzfp.CZY, mzfp.KDKS, mzfp.ZXKS" & Chr(13) & "" & Chr(10) & "ORDER BY mzfp.CZY, mzfp.KDKS, mzfp.ZXKS" _
)
.CreatePivotTable TableDestination:=Range("A1"), TableName:="数据透视表1"
End With
ActiveSheet.PivotTables("数据透视表1").SmallGrid = False
ActiveSheet.PivotTables("数据透视表1").AddFields RowFields:=Array("KDKS", "ZXKS"), _
ColumnFields:="CZY"
ActiveSheet.PivotTables("数据透视表1").PivotFields("Expr").Orientation = xlDataField
ActiveWindow.SelectedSheets.PrintPreview

若做过Excel数据透视表的同志最好能发个Email这些:lz_zzd@163.com,另外再加分。。。。
 
搜索ole,你可以找到好多帖子
 
后退
顶部