Created
March 4, 2011 07:46
-
-
Save taka2/854317 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Dim excelFileName, excelObj, workbookObj, worksheetObj | |
| ' 引数チェック | |
| If WScript.Arguments.Count <> 1 Then | |
| msgbox "Usage: neatexcel.vbs [Excel FileName]" | |
| WScript.Quit(1) | |
| End If | |
| excelFileName = WScript.Arguments(0) | |
| ' Excel起動 | |
| Set excelObj = CreateObject("Excel.Application") | |
| Set workbookObj = excelObj.Workbooks.Open(excelFileName) | |
| ' 各シートのCells(1, 1)を選択する | |
| For Each worksheetObj In workbookObj.Sheets | |
| worksheetObj.Select | |
| worksheetObj.Cells(1, 1).Select | |
| Next | |
| ' 先頭のシートを選択する | |
| workbookObj.Sheets(1).Select | |
| ' 上書き保存して閉じる | |
| workbookObj.Save() | |
| workbookObj.Close() | |
| excelObj.Quit() | |
| ' Excel終了 | |
| msgbox "done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment