Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 4th, 2003, 01:34 AM
Registered User
 
Join Date: Aug 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Implement server-side spell-checking with ASP and

Hello!!!
Help me, please, I can't find mistake for a 2 days!!!
When I gonna execute code below? I got following error message:

Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'Documents.Add'
/Test/sch.asp, line 34


Code:

Dim objWord 'Word.Application
Dim objDocument 'Word.Document
Dim objErrors 'Word.ProofreadingErrors
Dim objError 'Word.Range
Dim wdSuggestions 'Word.SpellingSuggestions
Dim wdSuggestion 'Word.SpellingSuggestion
Dim strSubmission, strModified, intCounter
Const wdDoNotSaveChanges = 0
'On Error Resume Next 'Uncomment this line in realise version of application
'Capture submitted text from Form or QueryString
strSubmission = Request("tMess")
If Trim(strSubmission) <> "" Then
'Echo submission back to the user
With Response
.Write "<b>"
.Write "Ðåçóëüòàò ïðîâåðêè ïðàâîïèñàíèÿ:</b>"
.Write "<br><br>"
.Write "<b>Ïðîâåðÿåìûé òåêñò:</b><br>"
.Write """ & strSubmission & ""<br><br>"
End With
'Launch Word and create a new document
Set objWord = Server.CreateObject("Word.Application")
If Not IsEmpty(objWord) Then
Set objDocument = objWord.Documents.Add
If Not IsEmpty(objDocument) Then
'Insert the user's submitted text into the document
objWord.Selection.TypeText CStr(strSubmission)
'Retrieve and display spelling errors
Set objErrors = objDocument.SpellingErrors
If objErrors.Count Then 'there are errors
With Response
.Write "<table><tr><td><b>Îøèáêè ïðàâîïèñàíèÿ "
.Write "</b></td><td><b>Ïðåäëîæåíèÿ ïî èñïðàâëåíèþ</b></td></tr>"
End With
For Each objError In objErrors
'Display the misspelled word
Response.Write "<tr valign=top><td>"
Response.Write objError.Text & "</td><td>"
'Get spelling suggestions for the word
Set wdSuggestions = objWord.getSpellingSuggestions(objError.Text)
If wdSuggestions.Count < 1 Then
Response.Write "Íåò ïðåäëîæåíèé"
Else
intCounter = 0
For Each wdSuggestion In wdSuggestions
intCounter = intCounter + 1
strModified = Replace(strSubmission, objError.text, wdSuggestion.name, 1, 1)
With Response
'Construct anchor tag
.Write "<a href=sch.asp?"
.Write "tMess="
.Write server.URLEncode(strModified)
.Write ">" & wdSuggestion.name & "</a>"
End With
'Display a pipe-delimiter except at the end
If intCounter < wdSuggestions.Count Then
Response.Write " "
End If
Next
End If
Response.Write "</td></tr>"
Next
With Response
'Show the user number of errors found
.Write "</table>"
.Write "<br><b>" & objErrors.count
.Write " Íàéäåíû îøèáêè:</b>"
.Write " Êëèêíèòå íà ñîâåòå äëÿ èñïðàâëåíèÿ."
End with
Else 'no errors were found
Response.Write "<b>Îøèáêè íå íàéäåíû.</b>"
End if
'Close running instance of Word and destroy objects
objWord.Quit wdDoNotSaveChanges
Set wdSuggestions = Nothing
Set objErrors = Nothing
Set objDocument = Nothing
Set objWord = Nothing
Else
objWord.Quit wdDoNotSaveChanges
Set objWord = Nothing
End If
End If
End If

Of course, I not so smart, most of this code snippet I taken from MSDN library and just do little error-handling here...anyway it doesn't work...and help me...

P.S. My english...really bad...I know...so, be friendly please...your Russian better...I hope.

 
Old September 9th, 2003, 04:33 PM
Registered User
 
Join Date: Sep 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

strSubmission = Request("tMess")

should be:

strSubmission = Request.QueryString("tMess")



 
Old September 14th, 2003, 03:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

trevorl> it does not matter. ASP Request Object first check QueryString then Form then Session then cookie.

Regards - Jon





Similar Threads
Thread Thread Starter Forum Replies Last Post
Server Side Viewstate in ASP.NET 2.0 vikaspatyal ASP.NET 2.0 Professional 1 December 18th, 2007 12:26 AM
Help with asp server side validation nkodali Classic ASP Basics 0 July 16th, 2007 04:02 PM
ASP.NET server side controls me_shriram VS.NET 2002/2003 3 August 11th, 2003 03:55 AM
New Feature: Spell Checking bluckcuck Forum and Wrox.com Feedback 10 July 2nd, 2003 09:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.