如何從vsto outlook插件搜索excel表單中的最後一個空單元格?vsto - VB - 在Outlook插件中查找列中的最後一個單元格
我有以下代碼(未編譯)
Imports Excel = Microsoft.Office.Interop.Excel
Dim ExcelApp As New Excel.Application
Dim ExcelWorkbook As Excel.Workbook
Dim ExcelWorkSheet As Excel.Worksheet= ExcelWorkbook.Worksheets(1)
Dim ExcelRange As Excel.Range = ExcelWorkSheet.Range("A1","A600")
Dim currentFind As Excel.Range = Nothing
Dim firstFind As Excel.Range = Nothing
currentFind = ExcelRange.Find("*", , Excel.XlFindLookIn.xlValues, Excel.XlLookAt.xlPart, Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlNext, False)
While Not currentFind Is Nothing
' Keep track of the first range you find.
If firstFind Is Nothing Then
firstFind = currentFind
' If you didn't move to a new range, you are done.
ElseIf currentFind.Address = firstFind.Address Then
Exit While
End If
currentFind = ExcelRange.FindNext(currentFind)
End While
ExcelWorkbook.ActiveSheet.range(currentFind).Select()
我已經更新它根據斯科特·霍爾茨曼的意見,但現在我得到一個錯誤信息:HRESULT:0x800A03EC
請將解決方案作爲答案發布,而不是作爲問題的更新。這是爲了避免未來訪客的混淆。這些更改不會完全丟失,您可以在[修訂](https://stackoverflow.com/posts/46711104/revisions)中找到它們。 – Bugs