ara*_*aku 15 command-line ms-word
我正在开发一个Web项目,其中客户端需要首先上传一些MS Word文档的功能,然后他可以比较任何两个上传的文档.
我想出的想法是首先使用WEBDAV使文档可用,然后使用命令行打开两个文档并使用"并排比较"选项.通过这种方式,他将能够比较和修改两个文档.
问题是,我无法找到任何可以从命令提示符运行的命令,以在比较模式下打开两个文档.
此外,如果您知道任何其他方式来实现此功能,请与我分享.
这可能是一种方法(对于Visual Studio 2010)
我将以下两个链接混合在一起
http://msdn.microsoft.com/en-us/library/vstudio/ee342218%28v=vs.100%29.aspx
到我添加的C#控制台项目添加了参考:.NET - > Microsoft.Office.Interop.Word版本14.0.0.0
来源:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Word = Microsoft.Office.Interop.Word;
//using Office = Microsoft.Office.Core;
//using Microsoft.Office.Tools.Word;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Word.Application wordApp = new Word.Application();
wordApp.Visible = false;
object wordTrue = (object)true;
object wordFalse = (object)false;
object fileToOpen = @"C:\Temp\1.docx";
object missing = Type.Missing;
Word.Document doc1 = wordApp.Documents.Open(ref fileToOpen,
ref missing, ref wordFalse, ref wordFalse, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref wordTrue, ref missing,
ref missing, ref missing, ref missing);
object fileToOpen1 = @"C:\Temp\2.docx";
Word.Document doc2 = wordApp.Documents.Open(ref fileToOpen1,
ref missing, ref wordFalse, ref wordFalse, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing);
Word.Document doc = wordApp.CompareDocuments(doc1, doc2, Word.WdCompareDestination.wdCompareDestinationNew, Word.WdGranularity.wdGranularityWordLevel,
true, true, true, true, true, true, true, true, true, true, "", true);
doc1.Close(ref missing,ref missing,ref missing);
doc2.Close(ref missing,ref missing,ref missing);
wordApp.Visible = true;
}
}
}
Run Code Online (Sandbox Code Playgroud)
去做: