在脚本方面我仍然是新手,所以如果这是我的一个简单错误,请原谅我。
我正在尝试使用我创建并使用 CMD 执行的 VBS 脚本在不断更新的 CSV 文件中显示最后一行。我一直在拉动和修改来自多个来源的代码。
到目前为止,我只能让它拉到最上面一排,不知道如何将它切换到底部。我的代码有点粗糙。任何帮助将不胜感激。
到目前为止,这是我的代码:
Option Explicit
Dim objExcel
Dim excelPath
Dim workSheetCount
Dim counter
Dim currentWorkSheet
Dim usedRowsCount
Dim row
Dim top
Dim Cells
Dim curRow
Dim word
excelPath = "c:\Test\test.csv"
WScript.Echo "Reading Data from " & excelPath
Set objExcel = CreateObject("Excel.Application")
objExcel.DisplayAlerts = 0
objExcel.Workbooks.open excelPath, false, true
workSheetCount = objExcel.Worksheets.Count
WScript.Echo "We have " & workSheetCount & " worksheets"
For counter = 1 to workSheetCount
WScript.Echo "-----------------------------------------------"
WScript.Echo "Reading data from worksheet " & counter & vbCRLF
Set currentWorkSheet = objExcel.ActiveWorkbook.Worksheets(counter)
usedRowsCount = currentWorkSheet.UsedRange.Rows.Count
top = currentWorksheet.UsedRange.Row
Set Cells = currentWorksheet.Cells
For row = 0 to (usedRowsCount-1)
curRow = row+top
word = Cells(curRow).Value
WScript.Echo (word)
Next
Next
Set currentWorkSheet = Nothing
objExcel.Workbooks(1).Close
objExcel.Quit
Set currentWorkSheet = Nothing
Set objExcel = Nothing