当前位置: 首页 > 图文教程 > 网络编程 > ASP > 使用ASP和Word进行服务器端拼写检查

ASP
ASP中数据库调用中常见错误的现象和解决方法
ASP取出HTML里面的图片地址的函数
关于分页查询和性能问题
利用Asp生成整站静态
用ASP+XMLHTTP编写一个天气预报程序
轻松检测浏览器是否接受Cookies信息
净化网络环境:ASP程序实现过滤脏话
入门:防范SQL注入攻击的新办法
如何对ASP.NET进行性能优化
ASP无法更新ACCESS数据库解决方法
ASP:利用ASP把图片上传到数据库
ASP:用ASP编程实现网络内容快速查找
ASP:用ASP打造一个小型的网页BBS系统
ASP:用Asp编程实现QQ的在线情况查询
通过表单创建word的一个例子
在ASP中轻松实现记录集分页显示
ASP中实现小偷程序的原理和简单示例
ASP:6行代码实现无组件上传
实用篇:用asp实现QQ在线查询
如何轻松打造ASP计数器

使用ASP和Word进行服务器端拼写检查


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 21 ::
收藏到网摘: n/a

  编译 甘冀平(2000-09-26)

本文讨论的问题与下列方面相关:

Microsoft Word 97 for Windows

Microsoft Visual InterDev, version 6.0

Microsoft Internet Information Server version 4.0



概要
本文描述了如何使用Microsoft Word在Web页面ASP文件中添加拼写检查功能。

详细的步骤
按照下列步骤建立ASP应用程序:

1、在Web服务器所在机器上,启动Microsoft Visual Interdev 6.0,选择File/New Project。

2、在“新工程”对话框的名字编辑域中,输入“WebSpell”,然后双击新Web工程图标。

3、在接着出现的Web工程向导对话框中,输入或者选择你的Web服务器名字。将工作模式默认为Master,点击Next,再点击
“finish”。

4、在Visual InterDev创建工程完成后,打开工程菜单,选择“添加Web Item\HTML页面”,命名为“CheckSpelling”,
然后点击Open。

5、添加的HTML页面默认状态下以设计视图打开。在页面上拖出一个HTML文本区域,放置一个HTML提交按钮,根据你的爱好
进行布局,在页面上输入一些文字,告诉用户在文本域中输入需要进行拼写检查的文字。

6、选择页面上的所有对象(CTRL+A),然后从Visual InterDev的 HTML菜单中选择Form,将对象包裹在表单中。

7、点击当前窗口底部的源码功能页面,切换到源码显示视图。修改HTML开放< FORM >标记的action属性值为
results.asp。

8、打开Project菜单,选择“添加Web Item\Active Server Page”,命名为“results”,然后点击“Open”。

9、对于新页面,切换到源码视图,在<BODY>标记之间输入下面的代码:

<!-- Page header -->

<p><center><font size=+4 color=red>Spelling Results</font></center><hr>

<!-- Show user the text they entered -->

<p>The text you entered was:<p>

<font color=blue><%=Request("TEXTAREA1")%></font><p><hr><p>

<!-- Begin server-side script to check spelling errors -->

<%

' Don't allow other sessions to re-enter :)

do while(Application("WordInUse") = 1)

loop

Application("WordInUse") = 1



' Get Word references created in global.asa.

dim wdApp

set wdApp = Application("WordApp")

dim wdDoc

set wdDoc = Application("WordDoc")



' Clear current contents.

dim wdRange

set wdRange = wdApp.Selection.Range

wdRange.WholeStory

wdRange.Delete

set wdRange = Nothing



' Add the text the web user entered.

dim txt

txt = Request("TEXTAREA1")

wdApp.Selection.TypeText CStr(txt)



' Check spelling without prompting.

'wdDoc.CheckSpelling , , 0



' Get spelling errors collection.

dim wdErrors

set wdErrors = wdDoc.SpellingErrors

%>



<% ' Handle no-error condition.

if wdErrors.Count = 0 then

%>

There were no spelling errors.

<%

' Otherwise build a table of suggestions.

else

%>

<!-- Build a table to show errors & suggestions -->

<font color=red>There were <%=wdErrors.Count%> spelling error(s).</font><p>

<TABLE border=1 cellPadding=1 cellSpacing=1 width=75%>

<TR>

   <TD><b><font size=+1>Word</font></b></TD>

   <TD><b><font size=+1>Suggestions</font></b></TD></TR>

<%

   for each wdError in wdErrors

     ' Write the word in question.

     Response.Write("<TR><TD>")

     Response.Write(wdError.Text)

     Response.Write("</TD><TD>")



     ' Get spelling suggestions for it.

     dim wdSuggestions

     set wdSuggestions = wdApp.GetSpellingSuggestions(wdError.Text)

  

     if wdSuggestions.Count <> 0 then

      ' a comma-separated list of suggestions.