自动化:如何自动转化.DOC为.docx? [英] Automation: how to automate transforming .doc to .docx?

查看:138
本文介绍了自动化:如何自动转化.DOC为.docx?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一大堆的文件夹中的.doc文件,我需要转换为.docx。

I have a bunch of .doc files in a folder which I need to convert to .docx.

要手动转换为.doc为.docx是pretty简单:

To manually convert the .doc to .docx is pretty simple:


  1. 在Word 2007中打开.doc

  2. 点击另存为...

  3. 保存为.DOCX

但是,这样做的数百个文件肯定是不好玩。 = P

However, doing this for hundreds of files definitely ain't fun. =p

你会如何自动化这个?

推荐答案

自动化Word。

如果您使用的是.NET,添加的Microsoft.Office.Interop.Word(确保它是12版 - 相当于Word 2007中这样你就可以实现以上)参考装配到您的项目,并使用它,它字应用到自动化做你想做上面做什么。伪code

If you are using .NET, add Microsoft.Office.Interop.Word (make sure it is version 12 - equivalent to Word 2007 so you can achieve the above) reference assembly to your project and use it it automate word app to do exactly what you want to do above. The pseudocode


  • 创建应用程序对象

  • 使用应用对象来打开文档(通过提供其文件名)

  • 使用应用程序对象通过向它的格式和输出文件名来执行另存为

  • 关闭当前文档

  • 循环通过上面的,直到你的所有文件完成

  • 家政code释放Word或文档对象

您可以找到大量的例子在谷歌,只需搜索词自动化在C#或沿这条线的东西。

You can find plenty of example on google, just search for Word Automation in C# or something along that line.

这篇关于自动化:如何自动转化.DOC为.docx?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆