不知是不是这样子
将代码保存为ansi编码的bat
先用excel打开想要删除的xls文件(只允许有一个xls文件被打开)
然后运行bat
运行完成后回到excel界面自行保存或另存或关闭文件- @if (0)/*==(0)/* echo off
-
- set n=100
- set s=45
- set /a e=n+16
-
- cscript //nologo //e:jscript "%~f0" %n% %s% %e%
-
- echo 完成,请回到excel界面自行保存或另存或关闭&echo.&pause&exit/b
- rem */@end
-
- var ess=new ActiveXObject("excel.sheet");
- ess.Application.Visible=false;
- ess.Application.ScreenUpdating=false;
- var nil=null,wb=nil;
- for(var e=new Enumerator(ess.Application.Workbooks);!e.atEnd();e.moveNext()){
- wb=e.item();break;
- }
- wb.ActiveSheet.Range(WScript.Arguments(1)+":"+WScript.Arguments(2)).Delete(-4162);
- wb=nil;
- ess.Application.Visible=true;
- ess.Application.ScreenUpdating=true;
- ess.Close(0);ess=nil;
复制代码
|