我正在尝试将Powerpoint Interop插件用于C#Winform程序。那部分似乎没问题,但名称空间Microsoft.Office.Core(MsoTriState需要)给了我一些问题。
我已经浏览了互联网以寻求帮助,并且共识是将COM选项卡中的引用添加到Microsoft Office 12对象库。不幸的是,我只有版本15,程序不接受(下面的错误)。我有使用参考设置确定。
安装Office 2007是唯一的方法吗?或者有没有办法强制程序接受15版?我在VS 2010上。
Errors: "the type "Microsoft.Office.Core.MsoTriState is defined in an assembly that is not referenced. You must add a reference to assembly 'office, version 12.0.0.0, Culture = neutral, Piblic key tokem = 71e9bce111e9429c'
"cannot convert from 'Microsoft.Office.Core.MsoTriState [xxx.NETFramework,Version=v4.0,Profile=Client.AssemblyAttributes.cs]' to 'Microsoft.Office.Core.MsoTriState' *projectfilepath*
代码:
using Core = Microsoft.Office.Core;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
PowerPoint.Presentation file;
int slideIndex = 0;
public PowerpointForm(string path)
{
InitializeComponent();
var app = new PowerPoint.Application();
var pres = app.Presentations;
file = pres.Open(path, Core.MsoTriState.msoTrue, Core.MsoTriState.msoTrue, Core.MsoTriState.msoFalse);
}
等
答案 0 :(得分:0)
您可以安装2007 Microsoft Office System Update: Redistributable Primary Interop Assemblies,然后添加对已安装的PIA程序集的引用。