找回密码
 立即注册
搜索

求助:这段代码似乎是要建立与EXCEL的链接关系,但不知道具体如何使用。

0
回复
267
查看
[复制链接]

19

主题

220

帖子

52

幻币

一流武者

Rank: 3Rank: 3

积分
285
QQ
2016-4-12 12:15:41 显示全部楼层 |阅读模式
How to update information within unrelated excel objects inserted in slides of a presentation
' ====== Class Module - EventClass =====Option ExplicitPublic WithEvents App As Excel.ApplicationPrivate Sub App_WorkbookDeactivate(ByVal Wb As Excel.Workbook)Call UpdateXLCellsEnd Sub' ====== End Of Class Module - EventClass =====' ======= Module =======Option Explicit' ------ Code Specific to Hooking into Excel Events -----Dim AppClass As New EventClassSub SetExcelHook()Set AppClass.App = Excel.ApplicationEnd SubSub UnHook()AppClass.App = NothingEnd Sub' ------ End Of Code Specific to Hooking into Excel Events -----Sub UpdateXLCells()Dim X As IntegerDim Y As VariantFor X = 2 To 4 Y = Y + GetXlRngValues(ActivePresentation.Slides(X).Shapes(1), "B2")NextSetXlRngValues ActivePresentation.Slides(1).Shapes(1), "B2", YEnd SubFunction GetXlRngValues(oShape As PowerPoint.Shape, _ Rng As String) As VariantDim XLObj As Excel.WorkbookDim CellValues As VariantSet XLObj = oShape.OLEFormat.ObjectGetXlRngValues = XLObj.Worksheets(1).Range(Rng)End FunctionSub SetXlRngValues(oShape As PowerPoint.Shape, _ Rng As String, Value As Variant)Dim XLObj As Excel.WorkbookDim CellValues As VariantSet XLObj = oShape.OLEFormat.ObjectXLObj.Worksheets(1).Range(Rng) = ValueEnd Sub' ===== End Of Code =====
H0UZNPRO.rar (33.04 KB, 下载次数: 251)
PPT学习论坛
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册