欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

VBS脚本

程序员文章站 2022-03-04 20:30:22
...

实现功能:对于classes1.xlsx、classes2.xlsx、classes3.xlsx、classes4.xlsx、classes5.xlsx五个班级的学生总分的相加;

VBS脚本

dim eapp, ebook, esheet,i,j,r
set eapp=CreateObject("excel.application")
for i=1 to 5
    set ebook=eapp.workbooks.open(("F:\学习\vbs\classes"& i)&".xlsx")
    
 	for each esheet in ebook.sheets
 	      esheet.range("G1").Value = "总分"
	      for r = 2 To 7
	      esheet.cells(r,7).value = esheet.cells(r,2).value + esheet.cells(r,3).value + esheet.cells(r,4).value +esheet.cells(r,5).value+esheet.cells(r,6).value
	      next 
    	next 
    ebook.save
    ebook.close
    set ebook = Nothing
	
next
eapp.quit
set eapp = nothing