Example of series of JAVA Script commands and JAVA Script instructions that can be
grouped as a single user JAVA Script command.
This code has been used with different options added. It allows the user (for example) to
spell check a selected text.
Create a text file with the extension JS.
Check that the File Type for JS is associated with:
&Open
C:\Windows\System32\WScript.exe "%1" %*
WScript
Open &with Command Prompt
C:\Windows\System32\CScript.exe "%1" %*
CScript
Start a shell process to work with
DomiShell= new
ActiveXObject("WScript.Shell");
Copy in the buffer whatever is highlighted:
DomiShell.SendKeys( "^c" );
Start Word object:
DomiWord= new ActiveXObject("Word.Application");
Start Word Application:
DomiWord= new ActiveXObject("Word.Application");
DomiWord.Visible= true;
Open a blank Word document:
DomiWord.Documents.Add();
Paste in Word whatever was copied earlier:
DomiWord.Selection.Paste();
Spell check the active document in Word:
DomiWord.ActiveDocument.CheckSpelling();
Select the complete text:
DomiWord.Selection.WholeStory();
Copy it in the buffer:
DomiWord.Selection.Copy();
Close document:
DomiWord.ActiveDocument.Close(0);
Close Word:
DomiWord.Quit();
Inform user, ask question using a dialog box:
var nRet= DomiShell.Popup( "Accept corrected text?\nClick OK to
replace the selected text.", 0, "Spellchecker ended successfully", 33 );
If user accepts, replace the selected text with the corrected text:
if ( nRet ==1 ) {
DomiShell.SendKeys( "^v" );
You can do about the same by using Excel:
Start Excel object:
DomiExcel = new ActiveXObject("Excel.Application");
Open a new sheet:
ExcelSheet = new ActiveXObject("Excel.Sheet");
Make Excel visible:
ExcelSheet.Application.Visible = true;
Place some text in the first cell of the sheet.
ExcelSheet.ActiveSheet.Cells(1,1).Value = "Dominique is placed
in column A, row 1";
Do the actual spell checking:
ExcelSheet.ActiveSheet.CheckSpelling();
Save the sheet:
ExcelSheet.SaveAs("C:\\TEST.XLS");
Close Excel:
ExcelSheet.Application.Quit();
Search the Microsoft web site with key words as: CreateObject("Excel.Sheet"), Set ExcelSheet = Nothing, Automate Excel from an HTML Web Page Using JScript, Automate PowerPoint, OLE Programmatic Identifiers
About me and my activities since 1995 - Developing solutions that really help - No gimmicks | ||
Participation on Google Participation on Yahoo! Tek-Tips Forums dgschnei |
Listed since 1996 ixquick International Services Vivísimo platform sdk dgschnei |
Cooperation on Google About Me Gifts Home Decoration |