请先在d盘下新建test.xls,然后将test.xls的sheet按顺序增加到10,也可以将1 to 10中的10 改为3,运行下面的vbs
就可以看到示例过程了:- '操作excel文本小示例
- dim counter '声明counter变量
- set objexcel=nothing '置空objexcel
- set objexcel=createobject("excel.application")
- objexcel.workbooks.open ("d:\test.xls")
- set wshshell=createobject("wscript.shell")
- objexcel.visible=true
- for counter=1 to 10
- objexcel.worksheets(counter).activate '设置当前页为活动页
- objexcel.cells(counter,1).value="现在操作第"&counter&"页"
- objexcel.cells(counter,1).activate '设置当前单元格为活动单元格
- wscript.sleep 200
- wshshell.sendkeys "{f2}{tab}{tab}finished{tab}" '用sendkey连续发送键
- next
- 'objexcel.activeworkbook.save '要保存操作请将ob前面的'去掉同时删除最后两行
- objexcel.quit
- wscript.sleep 1000
- wshshell.sendkeys "{tab}~"
复制代码
[ 本帖最后由 batman 于 2009-4-1 12:32 编辑 ] |