Written by D. G. Schneider ContactEZ.net


Sample of VBScript used as Macros for documentation - Open source - Spell Check Using Word

This simple VBscript will spell check any web page you are visiting.
You can also use it to spell check text you entered in a form field before pressing the "Send" button.
It gives you al the option Spellcheck offered by Word.
The user will have the choice to Ignore, Add, Change, AutoCorrect.
This script could be used by ebay users before sending the description of their items !:)

This simple VBscript will use Word Spellchecker to correct (if needed) the text entered in a form field.
The user will have the choice to Ignore, Add, Change, AutoCorrect.
If you are a translator, by changing the code, you call call translation software to send to translation the the text entered in a form field.

Open notepad, place the code below, save the file with HTML extension (the name you wish), Open Window Explorer and double-click the file you just saved.



<TITLE>Simple Spell Check Using Word</TITLE>



<H3>Simple Spell Check Using Word</H3><HR>

<FORM NAME="myForm" action="" onsubmit="SpellCheckOnClick(); return false;" language="jscript">

<LABEL FOR = "TEXTAREA2check"><strong>Type the text in this area:</strong></LABEL>






Sub SpellCheckOnClick()

	if Trim(myForm.TEXTAREA2check.Value) = "" then

		myForm.TEXTAREA2check.Value =  "Please enter text here!"


	Dim String2Check

	String2Check = Trim(myForm.TEXTAREA2check.Value)

            ' Create a Word document object...

               Set TheWordApp = CreateObject("Word.Application")

               Set TmpDocument = TheWordApp.Documents.Add


            ' Position Word off screen to avoid having document visible...

               lOrigTop = TheWordApp.Top

               TheWordApp.WindowState = 0

               TheWordApp.Top = -3000


             ' Assign the text to the document and check spelling...

               With TmpDocument


             ' .Content.paste if you want to paste strings from the clipboard

                 .Content.Text = String2Check



               ' After user has made changes, get text back...  

                myForm.TEXTAREA2check.Value =  .Content.Text          

               ' Close the document and exit Word...

                .Saved = False

                .Close (0)

               End With


		Set TmpDocument = Nothing

		TheWordApp.Top = lOrigTop


		Set TheWordApp = Nothing

	end if

End Sub




Example of series of VBScript Script commands and VBScript Script instructions that can be grouped as a single user VBScript command.
This code has been used with different options added.
It allows the user (for example) to spell check a selected text in an HTML form field.

Create a text file with the extension VBS.

Here is the main VBS engine:

You can launch it by creating a file with an HTML extension:

Passing variables from command line:

Command-line parameters in arguments collection:

Dim objArgs
Set objArgs = WScript.Arguments

    For I = 0 to objArgs.Count - 1
        WScript.Echo objArgs(I)
ArgumentPAssed =  objArgs(I)

For 1 command-line paramenter:

set objArgs = wscript.arguments
ArgumentPAssed = objargs(0)

Use of FileSystemObject to retrieve the file version for a .dll file:

Set objFSO = CreateObject("Scripting.FileSystemObject")
Wscript.Echo objFSO.GetFileVersion("c:\windows\system32\scrrun.dll")

Use FileSystemObject to enumerate (in English and French) the properties of a file:

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("c:\windows\system32\scrrun.dll")
Wscript.Echo "Date created: / Date de cr ation: " & objFile.DateCreated
Wscript.Echo "Date last accessed: / Date du dernier acc s: " & objFile.DateLastAccessed
Wscript.Echo "Date last modified: / Date de la derni re modification: " & objFile.DateLastModified
Wscript.Echo "Drive: / Disque: " & objFile.Drive
Wscript.Echo "Name: / Nom :" & objFile.Name
Wscript.Echo "Parent folder: / Dossier: " & objFile.ParentFolder
Wscript.Echo "Path: / Chemin d'acc s: " & objFile.Path
Wscript.Echo "Short name: / Nom court: " & objFile.ShortName
Wscript.Echo "Short path: / Chemin d'acc s court: " & objFile.ShortPath
Wscript.Echo "Size: /Taille: " & objFile.Size
Wscript.Echo "Type: " & objFile.Type

Return Home - Index