你可以給這個HTA一試:
<html>
<Title>Save file into noteapd and Word Application</Title>
<META HTTP-EQUIV="MSThemeCompatible" CONTENT="YES">
<head>
<HTA:APPLICATION
ICON="Notepad.exe"
APPLICATIONNAME = "Save file into noteapd and Word Application"
BORDER="dialog"
BORDERSTYLE="complex"
>
</head>
<script type="text/Vbscript">
'*****************************************************
Sub window_onload()
CenterWindow 500,350
End Sub
'*****************************************************
Sub CenterWindow(x,y)
Dim iLeft,itop
window.resizeTo x,y
iLeft = window.screen.availWidth/2 - x/2
itop = window.screen.availHeight/2 - y/2
window.moveTo ileft,itop
End Sub
'*****************************************************
Sub Save2Word()
'Create and Save a Word Document
Title = "Data saved into Word Appplication"
FileDoc = "C:\" & Month(Date) & "_" & Day(Date) & "_" & Year(Date) & ".doc"
Set objWord = CreateObject("Word.Application")
objWord.Visible = False
Txtarea = document.all("Txtarea").Value
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
objSelection.Font.Name = "Comic Sans MS"
objSelection.Font.Size = "12"
objSelection.TypeText Txtarea
objDoc.SaveAs(FileDoc)
objWord.Quit
MsgBox "Data saved into : " & FileDoc,vbInformation,Title
End Sub
'*****************************************************
Sub Save2Notepad()
'Save into a Notepad Document
Title = "Data saved into Notepad Appplication"
Set fso = CreateObject("Scripting.FileSystemObject")
FileTxt = "C:\" & Month(Date) & "_" & Day(Date) & "_" & Year(Date) & ".txt"
Txtarea = document.all("Txtarea").Value
Set oFile = fso.OpenTextFile(FileTxt,8,true)
oFIle.WriteLine Txtarea
oFile.Close
MsgBox "Data saved into : " & FileTxt,vbInformation,Title
End Sub
'*****************************************************
</script>
<body>
<center>
<form>
Enter your information:
<br>
<textarea ID="Txtarea" NAME="Txtarea" cols="40" rows="12"></textarea>
<hr>
<input type="button" value="save into word" onClick="Save2Word()"/>
<input type="button" value="save into notepad" onClick="Save2Notepad()"/>
<hr>
</form>
</center>
</body>
</html>