Excelファイルのページ数をカウントするスクリプト

Excelファイルのページ数をカウントするスクリプト.vbs

Set args = WScript.Arguments

Set fs = CreateObject("Scripting.FileSystemObject")
Set objFso = CreateObject("Scripting.FileSystemObject")

For Each file in args

  Set objFile = objFso.createtextfile(file & "_page.txt",2,TRUE)
  objFile.WriteLine file

  Set objExcel = CreateObject("Excel.Application")
  Set objBooks = objExcel.WorkBooks.Open(file,,TRUE)

  page = 0
  For Each sheet In objExcel.WorkSheets
    sheet.select
    objFile.WriteLine sheet.name & ":" &
    objExcel.Application.ExecuteExcel4Macro("get.document(50)")
    page = page + objExcel.Application.ExecuteExcel4Macro("get.document(50)")
  Next

  objFile.WriteLine "総ページ数 :" & page

  objExcel.Quit
  objFile.Close

Next

msgbox "done."

Excelがないと動かないよ