VBS 操作Excel
阿新 • • 發佈:2018-06-11
打開 user obj test AS msg nbsp name workbook
VBS操作Excel
-
打開excel
Dim objExcel,objWorkbook,objSheet
Set objExcel=CreateObject("excel.application")
Set objBook=objExcel.Workbooks.Open("\\MGPCTFSW01\UserFolders$\t165050\Desktop\Portal_Smoke_Automation\Test Data\Book1.xlsx")
-
讀取Excel
a.
Set objSheet=objbook.Sheets("sheet1")
msgbox objSheet.cells(2,2)
Set objBook=Nothing
Set objSheet=Nothing
objExcel.Quit
b.
Set objSheet=objbook.Sheets(SheetName)
Set objRange = objSheet.UsedRange
objRow = objRange.Find(RowName).Row
objColumn = objRange.Find(ColumnName).Column
objValue = objSheet.Cells(objRow,objColumn)
VBS 操作Excel