0

我添加了对Microsoft.Office.Interop.Word 12.0.0.0. 我有 Visual Studio 2008 和 Microsoft Word 2010(Starter)。

string filePath = @"C:\PP.docx";
Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.ApplicationClass();

// create object of missing value
object miss = System.Reflection.Missing.Value;

// create object of selected file path 
object path = filePath;

// set file path mode 
object readOnly = false;

// open document                 
Microsoft.Office.Interop.Word.Document docs = word.Documents.Open(ref path, ref miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);

// select whole data from active window document
docs.ActiveWindow.Selection.WholeStory();

// handover the data to cllipboard 
docs.ActiveWindow.Selection.Copy();

// clipboard create reference of idataobject interface which transfer the data
System.Windows.Forms.IDataObject data = Clipboard.GetDataObject();

我收到下面提到的错误:

由于以下错误,检索具有 CLSID {000209FF-0000-0000-C000-000000000046} 的组件的 COM 类工厂失败:80040154. at Microsoft.Office.Interop.Word.Application word => new Microsoft.Office.Interop.Word .ApplicationClass();

谢谢,萨钦K

4

1 回答 1

1

Office Starter 2010 版本受到限制,不支持自动化。

您需要获得适当的完整 Office 套件(例如专业版)。

有关限制的更多信息,请参阅http://www.microsoft.com/oem/en/products/office/pages/office_2010_starter.aspx

于 2012-06-25T10:29:56.953 回答