首页 > 其他 > 详细

调用COM方法

时间:2014-03-02 08:25:30      阅读:456      评论:0      收藏:0      [点我收藏+]

请先引用Microsoft.Office.Interop.Word.dll

调用Word里的拼写检查方法,注意需要先安装了Word.

CODE:

using System;
using System.Reflection;
using Microsoft.Office.Interop.Word;

namespace CsStudy
{
    class Pro
    {
        static void Main()
        {
            string str = Console.ReadLine();
            string res;
            int errs = 0;
            if (str.Length == 0)
                res = "No string";
            else
            {
                Application app = new Application();
                Console.WriteLine("\nChecking the string for misspellings... ");
                app.Visible = false;
                Document tmpDoc = app.Documents.Add();
                tmpDoc.Words.First.InsertBefore(str);
                ProofreadingErrors spellErr = tmpDoc.SpellingErrors;
                errs = spellErr.Count;

                tmpDoc.CheckSpelling(Missing.Value, true, false);//COM方法
                app.Quit(false);
                res = errs + " errors found";
            }
            Console.WriteLine(res);
            Console.ReadKey();
        }
    }
}

显示:


bubuko.com,布布扣

调用COM方法,布布扣,bubuko.com

调用COM方法

原文:http://blog.csdn.net/u013384702/article/details/20214643

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!