以编程方式阅读Microsoft Word文档 [英] Programmatically reading a Microsoft Word document

查看:147
本文介绍了以编程方式阅读Microsoft Word文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的学生将其Microsoft Word分配提交给ColdFusion 10服务器。我想写一个错误检查程序来检查常见的错误,如在标题中没有页码,标题页上的学校名称,他们在标题页上的名称等。我指定了很多APA规则。示例:短语Running head:必须在第1页的标题部分,但不能在文章的其余部分。我为每个规则指定一个点值。

I have my students submit their Microsoft Word assignments to a ColdFusion 10 server. I'd like to write an error checker to check for common mistakes like not having a page number in the header, the name of the school on the title page, their name on the title page, etc. I specify a lot of APA rules. Example: The phrase "Running head:" must be in the header section of page 1 but not the rest of the paper. I assign a point value to each rule.

理想情况下,这个错误检查器将在提交作业时立即运行。这可能需要使用

Ideally, this error checker would run when they submit the assignment and tell them immediately. That might require using

parser.parseFromString(str, "text/xml");

但是作为一个替代,如果我可以编写一个程序,我运行检查错误,帮助我自动分级。换句话说,使用Microsoft Access或Visual Studio。
但是我不想这样做,因为那时我必须在服务器上安装Visual Studio,我不认为这是可行的。

But as an alternate, if I could write a program that I run to check for errors, that could help automate my grading. In other words, using Microsoft Access or Visual Studio. But I don't want to do that because then I'd have to have Visual Studio on the server and I don't think that's going to be feasible.

最后一个选项是从服务器下载所有的论文,并在本地运行一个程序,这比手动分级要好一步。

The last option would be to download all the papers off the server and run a program locally, which is one step better than grading everything manually.

推荐答案

我这几年回来使用VBA,请参考文章。以下是解析文档每个段落的摘要:

I did this a few years back using VBA, refer to this article. Here is an excerpt that parses each paragraph of a document:

Public Sub ParseLines()
    Dim singleLine As Paragraph
    Dim lineText As String

    For Each singleLine In ActiveDocument.Paragraphs
        lineText = singleLine.Range.Text

        '// parse the text here...

    Next singleLine
End Sub

这篇关于以编程方式阅读Microsoft Word文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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