// JScript. //==========================================
var Word, Doc, Uncorrected, Corrected; var wdDialogToolsSpellingAndGrammar = 828; var wdDoNotSaveChanges = 0; Uncorrected = "Helllo world!"; Word = new ActiveXObject("Word.Application"); Doc = Word.Documents.Add(); Word.Selection.Text = Uncorrected; Word.Dialogs(wdDialogToolsSpellingAndGrammar).Show(); if (Word.Selection.Text.length != 1) Corrected = Word.Selection.Text; else Corrected = Uncorrected; Doc.Close(wdDoNotSaveChanges); Word.Quit(); ' VBScript. '==========================================
Dim Word, Doc, Uncorrected, Corrected Const wdDialogToolsSpellingAndGrammar = 828 Const wdDoNotSaveChanges = 0 Uncorrected = "Helllo world!" Set Word = CreateObject("Word.Application") Set Doc = Word.Documents.Add Word.Selection.Text = Uncorrected Word.Dialogs(wdDialogToolsSpellingAndGrammar).Show If Len(Word.Selection.Text) <> 1 Then Corrected = Word.Selection.Text Else Corrected = Uncorrected End If Doc.Close wdDoNotSaveChanges Word.Quit
②FSOでファイルを操作
' VBScript. ' MYDIR.VBS Option Explicit Dim FSO Set FSO = CreateObject("Scripting.FileSystemObject") DoDir FSO.GetFolder(".") Sub DoDir(Folder) On Error Resume Next Dim File, SubFolder For Each File In Folder.Files WScript.StdOut.WriteLine File.Path Next For Each SubFolder in Folder.SubFolders DoDir SubFolder Next End Sub
③RegExpでパラメータを解析して、ファイルを探す
' MyGrep.VBS Option Explicit Dim RE, Line If WScript.Arguments.Count = 0 Then WScript.Quit Set RE = New RegExp RE.IgnoreCase = True RE.Pattern = WScript.Arguments(0) While Not WScript.StdIn.AtEndOfStream Line = WScript.StdIn.ReadLine If RE.Test(Line) Then WScript.StdOut.WriteLine Line WEnd
没有评论:
发表评论