【问题标题】:Import excel chart with spin button to powerpoint将带有旋转按钮的 excel 图表导入到 powerpoint
【发布时间】:2013-06-01 14:37:36
【问题描述】:

我在 excel 中有一个带有旋转按钮的图表,该按钮在按下时更改值以更改图表。我可以使用 insert -> object 将它们导入到 powerpoint 中,但这不会使旋转按钮可用。

我正在尝试获取它,因此在显示演示文稿时,我可以单击旋转按钮,图表将相应更改,就像它在 excel 中一样。这可能吗?

【问题讨论】:

  • superuser.com 上的这个问题可能会让你更幸运。
  • @Stewbob 这可能是一个与 VBA 相关的问题(或解决方案)。旋转按钮几乎可以肯定附加到宏,当图表对象被复制到 PPT 文件中时,它可能不会持续存在。 OP 需要复制宏的代码并将其放入图表数据表工作簿中的代码模块中,此时可能需要进行一些调整。

标签: excel vba powerpoint


【解决方案1】:

旋转按钮连接到一个宏,这就是导致 Excel 中的图表发生变化的原因。

您可以从 Excel 复制代码并将其放在 Powerpoint 文件中的标准模块中。

您可能需要进行一些调整——或多或少,这取决于原始宏的编写情况(例如,如果它充满了ActiveSheet.ThisActiveChart.That,那么它将需要更多的调整而不是使用ChartChartObject 变量来表示图表。

这是一个与 powerpoint 图表交互的示例:

Sub TEST()
Dim sld As slide
Dim cht As Chart
Dim srs As Series

Set sld = ActivePresentation.Slides(1) 'Modify to be the correct slide #'

'You can hardcode the shape by index if you know it, otherwise'
' this method will apply to the FIRST chart object found on the slide'
For i = 1 To sld.Shapes.count
    If sld.Shapes(i).Type = msoChart Then
        Set cht = sld.Shapes(i).Chart
        Exit For
    End If
Next

'use a variable to interact with the Series:'
Set srs = cht.SeriesCollection(1) '<Modify as needed.'

'specify a particular formula for the series:'
'your macro likely changes the chart's source data/formula information'
' so something like this:'    
srs.Formula = "=SERIES(Sheet1!$B$1,Sheet1!$A$2:$A$5,Sheet1!$B$2:$B$5,1)"

'Or you can display the series formula:'
MsgBox srs.Formula

'Or you can toggle the series axis group:'
With srs
If Not .AxisGroup = xlSecondary Then
    .AxisGroup = xlSecondary
Else
    .AxisGroup = xlPrimary
End If


'etc.'
'Basically anything you can do to an Excel chart in VBA, you can do in PPT.'

End With

End Sub

【讨论】:

    【解决方案2】:

    当您将任何内容从 Excel 复制/粘贴到 PowerPoint 时,您会得到一个 OLE 对象。 PowerPoint 中显示的是您从 Excel 复制的任何内容的 Windows 图元文件图片。您必须激活 Excel 内容(在 PPT 的正常视图中双击它,或者为其提供适当的操作设置以使其在幻灯片放映期间激活)。然后微调器也应该在启动的 Excel 实例中工作。

    或者您可以在 PPT 中创建另一个微调器并让它运行代码来修改图表(使用 David 的示例代码作为基础)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-04
      • 1970-01-01
      • 2022-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多