如何从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