【问题标题】:Exchanging variables between powerpoint and excel VBA在 powerpoint 和 excel VBA 之间交换变量
【发布时间】:2010-09-24 11:15:28
【问题描述】:

我有一个 powerpoint pres,可以在按下按钮时从 Excel 工作表中获取一些数据。

Set EXL = New Excel.Application
EXL.Visible = False

Dim XLApp As Excel.Application

Set XLApp = GetObject(, "Excel.Application")

这就是我设置新的 excel 应用程序的方式。

我想知道如何将我的 powerpoint 幻灯片中的变量发送到 excel 工作簿中?我的 powerpoint 幻灯片中有文本字段,我希望在 excel 中的变量中使用文本。这可能吗?如果有,怎么做?

我如何从 powerpoint 模块调用 excel 工作簿中的 Sub 来运行?

【问题讨论】:

    标签: excel vba variables powerpoint


    【解决方案1】:

    (这是来自 Access db 的一些简化生产代码,powerpoint 可能有一些细微差别)

    What I'm wondering is how I can send over a variable from my powerpoint slide into the excel workbook?

    Sub SetXLCellValue( _
        FileStr As String, _
        TabStr As String, _
        Cell As String)
    
        Dim XLApp As New Excel.Application
        Dim ObjXL As Excel.Workbook
        Set ObjXL = XLApp.Workbooks.Open(FileStr)
    
        ObjXL.Worksheets(TabStr).Range(Cell).value = value
        ObjXL.Save
        ObjXL.Close True
    End Sub
    

    【讨论】:

      【解决方案2】:

      至于在你的 Excel 应用中调用 Sub,你可以使用

      XLApp.Run("MySub")
      

      这也有向方法传递参数的能力(intellisense 应该会告诉你方法)

      【讨论】:

        猜你喜欢
        • 2018-02-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-02-09
        • 2012-12-23
        • 1970-01-01
        • 2017-10-25
        相关资源
        最近更新 更多