We can use VBScript to quickly batch some Excel files. The VBScript script needs to be saved as a. vbs file, which is very convenient to run by double-clicking.
The following is sample code, save as a Run.vbs file:
' On Error Resume Next
' Define params:
Im Excelapp
Im Objworkbook
Im Objimportsheet
Im path
Path = "C:/users/administrator/desktop"
' Open Excel:
' From http://www.bianceng.cn
Set Excelapp = CreateObject ("Excel.Application")
Excelapp.visible = False
Set Objworkbook = ExcelApp.Workbooks.Open (Path & "/1.xls")
Set Xlssheet = objworkbook.sheets ("Sheet1") ' page number is called
' Read datas:
MsgBox "First Row first column value:" & Xlssheet.cells (1,1). Value
MsgBox "The second row of the first column value:" & Xlssheet.cells (2,1). Value
MsgBox "Second row of second column value:" & Xlssheet.cells (2,2). Value
' Set cells Data:
Xlssheet.cells (3,1). value= "inserted data ..."
MsgBox "The third row of the first column value:" & Xlssheet.cells (3,1). Value
' Save
Objworkbook.saveas Path & "/new.xls"
' Objworkbook.save
' Close
Objworkbook.close
' Clean & Quit:
Excelapp.quit
Set Objworkbook = Nothing
Set Objimportsheet = Nothing
Set excelapp = Nothing