8
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Jscript/Excel 覚え書き1

8
Last updated at Posted at 2014-10-20

覚え書き(1)

新規のExcelファイルを作成・実行する(1)

OpenExcel.js
var Excel = new ActiveXObject("Excel.Application");
Excel.Visible = true;              //Excelを表示する
var book = Excel.Workbooks.Add();  //新規ブック

//なにか仕事をする。

book.SaveAs("Book1.xlsx");  //新規保存(おそらくドキュメントフォルダへ)
book.Close();
Excel.Quit();

既存のExcelファイルを実行する(2)

OpenExcel.js
var Excel = new ActiveXObject("Excel.Application");
Excel.Visible = true;
var book = Excel.Workbooks.Open("ファイル名");  //既存のファイルをオープン

//なにか仕事をする。

book.Close(true);    //上書き保存する
Excel.Quit();

Close(true);で上書き保存で終了(確認なし)
Close(true);で保存しないで終了(確認なし)
Close();で確認のダイアログボックスが表示される

既存のExcelファイルを実行する(3)

 excelファイルを.jsファイルにドロップして指定

OpenExcel.js
var Excel = new ActiveXObject("Excel.Application");
Excel.Visible = true;

var objArg=WScript.Arguments;
var book = objXL.Workbooks.Open(objArg(1));  //ドロップされたファイルをチェックしていません。

//なにか仕事をする。

book.Close(true);
Excel.Quit();
8
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?