VBS 操作Excel

 VBS操作Excel

  1. 打开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")

  2. 读取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)

 

posted on 2018-06-11 18:07  Amy_Hu  阅读(2234)  评论(0编辑  收藏  举报