c# - 使用 C# VSTO 插件获取选定的图表对象或文本框或表格?
问题描述
我试图为 VSTO 插件获取 PPTX 文件中存在的当前选定对象。
我使用下面的包在幻灯片中创建图表、表格和文本。
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using Office = Microsoft.Office.Core;
我在 Ribben 栏中有一个按钮。一旦用户单击它,我想在任何幻灯片中获取当前选定的对象。我该怎么做呢?interop
包里有没有办法。
解决方案
如果您选择一个或多个形状,您可以执行以下操作
if (Globals.ThisAddIn.Application.ActiveWindow.Selection.ShapeRange.Count > 0)
{
//iterate over all the shapes selected by the user
foreach (PowerPoint.Shape shp in Globals.ThisAddIn.Application.ActiveWindow.Selection.ShapeRange)
{
if (shp.HasTable == Office.MsoTriState.msoTrue)
{
//Do something
}
if (shp.HasChart == Office.MsoTriState.msoTrue)
{
//Do something
}
if (shp.HasTextFrame == Office.MsoTriState.msoTrue)
{
//Do something
}
//or you could just return the shp object
}
}
推荐阅读
- vba - Powerpoint - 通过 VBA 将组保存为图像
- android - 您的应用尚未获准加入亲子同乐,并且更新未在 Google Play 上发布
- php - 从 created_at 字段获取日期和时间
- git - 从 Bitbucket 克隆存储库的特定文件夹
- php - 如何使用 htaccess angular 4 prod 重定向除两个文件夹内容之外的所有请求
- gulp - 如何在服务工作者中缓存 webp 图像?
- css - 如何文本对齐跨度/标签文本端点应该垂直相同?
- python - 每当我创建一个 venv 然后 pip freeze 仍然显示所有全局包
- node.js - 需要一些关于 Promise 中的 Promise 的建议以及如何更好地编写它
- javascript - 为什么 React Fibre 会多次调用 componentWillMount?