ちょっと作ってみたツール

SEを10年くらいやっていました。あったら便利だなーってツールを書いています

PrintScreenする度にExcelに張り付けるスクリプト

使い方

  1. 下のソースを適当なvbsにコピーする
  2. Excelを開き、適当な名前で保存する。このときファイルは閉じない。
  3. 1.で作ったvbsを次のコマンドで実行 cscript (1.で作ったvbs)
  4. PrintScreenを押すと、Excelの下に画像が張り付けられます
  5. 使い終わったら3.をCtrl+Cで終了させてください

ソース

span = 2 
col = 2

Set excel = GetObject(, "Excel.Application")   

row = getRow

WScript.Echo(row)


While True
  For Each fmt In excel.ClipboardFormats
    If fmt = 9 Then
      row = getRow
      excel.ActiveSheet.Cells(row + span, col).Select
      excel.ActiveSheet.Paste
      excel.ExecuteExcel4Macro "CALL(""User32"", ""OpenClipboard"", ""JJ"", 0)"
      excel.ExecuteExcel4Macro "CALL(""User32"", ""EmptyClipboard"", ""J"")"
      excel.ExecuteExcel4Macro "CALL(""User32"", ""CloseClipboard"", ""J"")"
    End If
  Next  
  WScript.Sleep 500
Wend

Function getRow()
  bottom = excel.ActiveSheet.UsedRange.Top + excel.ActiveSheet.UsedRange.Height
  For Each shape In excel.ActiveSheet.Shapes
    If shape.Top + shape.Height > bottom Then
      bottom = shape.Top + shape.Height
    End If
  Next

  row = 1
  While excel.ActiveSheet.Cells(row, 1).Top < bottom
    row = row + 1
  Wend
  getRow = row
End Function

when screen shot, paste it to active excel