阅读2010年Word文件

时间:2012-06-21 10:35:06

标签: c# asp.net interop ms-word

我添加了对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检索组件的COM类工厂   {000209FF-0000-0000-C000-000000000046}由于以下原因而失败   错误:80040154.在Microsoft.Office.Interop.Word.Application word =>新的Microsoft.Office.Interop.Word.ApplicationClass();

谢谢, Sachin K

1 个答案:

答案 0 :(得分:1)

Office Starter 2010版本有限,不支持自动化。

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

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