自定义功能区按钮将文本框添加到演示文稿中的活动幻灯片

编程入门 行业动态 更新时间:2024-10-08 02:20:24
本文介绍了自定义功能区按钮将文本框添加到演示文稿中的活动幻灯片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

全部,

我正在创建一个带有按钮的自定义功能区选项卡的Powerpoint加载项。

I am creating a Powerpoint add-in that has a custom ribbon tab with a button.

单击按钮时,我想在活动幻灯片上添加一个形状(例如,文本框)。

On button click, i want to add a shape (e.g., textbox) on the active slide.

我遇到的挑战是我不知道如何从中引用Slide对象自定义功能区类

Challenge I am running into is that I do not know how to refer to Slide object from the custom ribbon class

Imports Microsoft.Office.Tools.Ribbon Public Class Ribbon1 Private Sub Ribbon1_Load(ByVal sender As System.Object, ByVal e As RibbonUIEventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(sender As Object, e As RibbonControlEventArgs) Handles Button1.Click ''''''How do i reference active slide in this event??? End Sub End Class

我已经在Powerpoint VBA中编程了很多,但是很新的使用Visual Studio创建VSTO插件。

I have programmed a lot in Powerpoint VBA, but new to using Visual studio to create VSTO plugin.

非常感谢任何帮助!

N

推荐答案

嗨Nishsar,

Hi Nishsar,

它类似于VBA,但你需要首先获得Application对象,然后你可以通过ActiveWindow.View.Slide引用活动的幻灯片对象。

It's similar with VBA, but you need to get Application object at first and then you could refer to active slide object via ActiveWindow.View.Slide .

这是一个例子。

Imports PPT = Microsoft.Office.Interop.PowerPoint Dim app As PPT.Application = Globals.ThisAddIn.Application Dim pre As PPT.Presentation = app.ActivePresentation Dim sli As PPT.Slide = app.ActiveWindow.View.Slide Dim shp As PPT.Shape = sli.Shapes.AddShape(Type:=Microsoft.Office.Core.MsoAutoShapeType.msoShapeRectangle, _ Left:=150, Top:=150, Width:=50, Height:=50) shp.Fill.ForeColor.RGB = RGB(100, 100, 100)

问候,

Celeste

更多推荐

自定义功能区按钮将文本框添加到演示文稿中的活动幻灯片

本文发布于:2023-10-31 10:22:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545799.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   幻灯片   文本框   按钮   演示文稿

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!