Powerpoint VBA:是否可以让用户使用鼠标/键盘在Excel中select范围?

在Excel中,用户可以通过用鼠标或键盘select一个单元格范围(例如,下图),或者在input模式下input公式,然后继续select范围细胞):

在这里输入图像描述 有谁知道这样的function是否可以从Powerpointmacros/加载项中调用? 本质上,我想在Powerpoint中有一段代码,它生成一个类似的对话框,允许用户直接selectExcel电子表格中的一系列单元格,并让PPTmacroslogging那个范围是什么。

谢谢!

这里是你使用GetObject的例子

注意Application.InputBox以模态方式打开。 您不能跨工作簿使用它。

 Option Explicit Sub GetAddressFromExcel() Dim oXLApp As Object Dim Ret As Object '~~> Establish an EXCEL application object Set oXLApp = GetObject(, "Excel.Application") '~~> Show Excel oXLApp.Visible = True If oXLApp.Workbooks.Count = 0 Then oXLApp.Workbooks.Add End If On Error Resume Next Set Ret = oXLApp.InputBox("Please select Excel Range", Type:=8) On Error GoTo 0 If Not Ret Is Nothing Then MsgBox Ret.Address '~~> CLEANUP oXLApp.Quit Set oXLApp = Nothing End Sub