Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net VS 2012加载项快速插件_Vb.net_Visual Studio 2012_Powerpoint_Add In - Fatal编程技术网

Vb.net VS 2012加载项快速插件

Vb.net VS 2012加载项快速插件,vb.net,visual-studio-2012,powerpoint,add-in,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 D

我正在尝试为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


提前谢谢。

这里没有语法错误吗?应该是演示文稿,而不是演示文稿。演示文稿=PowerPointApp.ActivePresentationsAnks用于回复!但在我更改后,它出现了一个错误:尝试运行通过反射调用的方法引发的project uncaught异常时出错。您可能可以查看调试器中的异常消息文本,即它说明了什么问题,并在此基础上决定应修复的内容。它表示:创建了对嵌入式互操作程序集“office”的引用,因为程序集“Microsoft.office.interop.PowerPoint”间接引用了该程序集。考虑在任何一个程序集上更改“嵌入互操作类型”属性。您是否尝试执行消息所说的——即更改Office或PowerPoint程序集的嵌入互操作类型?