【发布时间】:2017-04-19 03:19:21
【问题描述】:
我有一个对象组(名为“组 5”),其中包含图表(名为“图表 1”)和图像(名为“图片 3”),我想将此对象组从 Excel 复制到 Powerpoint。
以前我只有 Excel 中的图表,我知道如何使用以下代码复制和粘贴到 powerpoint。
// Get the ChartObjects collection for the sheet.
chartObjects = (Excel.ChartObjects)(xlWorkSheetTemplateChart.ChartObjects(paramMissing));
// Get the chart to copy.
existingChartObject = (Excel.ChartObject)(chartObjects.Item("Chart 1"));
// Copy the chart from the Excel worksheet to the clipboard.
existingChartObject.Copy();
Thread.Sleep(1500);
// Paste the chart into the PowerPoint presentation.
shapeRange = pptPresentation.Slides.Range(IntialSlideCount).Shapes.Paste();
但是当将图表与图像分组时,上面的代码会出错,然后我不知道如何用C#编写代码。请帮忙。
【问题讨论】:
-
大家都猜不透:错误码是....???
-
当您使用组或 Groupshapes 时,您必须使用 groupshapes collection 您的代码只处理 Chartobjects,没有 GroupShpaes
-
我第一次将图表名称更改为“第 5 组”时出现错误“未找到具有指定名称的项目。”之后,我通过放置 Shape.Range(Array("Chart 1","Picture 3")) 尝试了其他方法,但仍然无法正常工作。出现错误“不可调用的成员 Shape.range[object] 不能像方法一样使用”。你有 C# 中的代码吗?我从谷歌查了一下,很多都是 VB...
-
Puh 从哪里开始:您的 chartobjects 集合没有名为“Group 5”的成员,因此您必须扫描集合。但是你的主要问题是你定义了一个苹果,但后来你说它现在是一个梨。这行不通!忘记第一时间将它翻译成 C#,你首先要明白你想要什么。对我来说你的问题还不清楚
-
我最初的意图只是将图表(图表1)从excel复制并粘贴到powerpoint。所以我正在使用 ChartObjects。但稍后,我需要将图片与图表组合在一起,然后仅从 excel 复制并粘贴到 powerpoint。我知道 ChartObjects 不再可用于对象分组。但我尝试用 C# 编写它,但无法完成。我什至尝试录制宏并查看 VBA 代码,并尝试调用类似的东西也不起作用。
标签: c# excel powerpoint