VS 2012加载快递插件

时间:2014-11-16 16:02:15

标签: vb.net visual-studio-2012 powerpoint add-in

我正在尝试使用Powerpoint的新幻灯片按钮创建功能区选项卡。 这是我用于按钮的代码:

Dim ppts As PowerPoint.Presentations = PowerPointApp.ActivePresentation
Dim oSlides As PowerPoint.Slides
Dim oSlide As PowerPoint.Slide
Dim oShapes As PowerPoint.Shapes
Dim oShape As PowerPoint.Shape
Dim oTextFrame As PowerPoint.TextFrame
Dim oTextRange As PowerPoint.TextRange
Dim oFont As PowerPoint.Font

oSlides = ppts.Slides
oSlide = oSlides.Add(1, PowerPoint.PpSlideLayout.ppLayoutTitleOnly)
oShapes = oSlide.Shapes
oShape = oShapes.Item(1)
oTextFrame = oShape.TextFrame
oTextRange = oTextFrame.TextRange
oTextRange.Text = "My sample presentation"
oFont = oTextRange.Font
oFont.Name = "Comic Sans MS"
oFont.Size = 48

我不打算打开新演示文稿并添加新幻灯片,但在已打开的演示文稿中添加了新幻灯片。

我收到一条错误消息: 用户代码未处理InvalidCastException

无法将“Microsoft.Office.Interop.PowerPoint.PresentationClass”类型的COM对象强制转换为接口类型“Microsoft.Office.Interop.PowerPoint.Presentations”。此操作失败,因为对IID为“{91493462-5A91-11CF-8700-00AA0060263B}”的接口的COM组件的QueryInterface调用由于以下错误而失败:不支持此类接口(HRESULT异常:0x80004002(E_NOINTERFACE))

提前致谢。

0 个答案:

没有答案