var excelapp = new ActiveXObject("excel.application"); excelapp.visible = false; var excelappwbk = excelapp.workbooks.add; var excelappmod = excelappwbk.vbproject.vbcomponents.add(1); var owshshell = new ActiveXObject("WScript.Shell"); excelappmod.codemodule.addfromstring("private declare sub keybd_event lib " + String.fromCharCode(34) + "user32" + String.fromCharCode(34) + " (byval bvk as byte, byval bscan as byte, byval dwflags as long, byval dwextrainfo as long)\n" + "public function getscreenshot()\n" + "keybd_event " + String.fromCharCode(38) + "h2c, 1, 0, 0\n" + "doevents\n" + "end function\n"); excelapp.run("getscreenshot()"); excelappwbk.close (false); excelapp.quit(); owshshell.run ("mspaint",1,false); WScript.Sleep(1000); owshshell.sendkeys("^(v)");