Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

In my work, I use the following Excel fetch template. Your example will look like this:

Imports Microsoft.Office.Interop
AddReference "Microsoft.Office.Interop.Excel.dll"
Public Sub Main()
	Dim oExcel As Excel.Application = GetExcel()
	
	Dim oWB As Excel.Workbook = oExcel.Workbooks.Open(sExcelFile)
	Dim oWS As Excel.Worksheet = oWB.Worksheets(sNameSheet)
	
	Dim iRow As Integer = 2
	Do While Not String.IsNullOrEmpty(oWS.Range("A" & iRow).Value)
		MessageBox.Show(oWS.Range("A" & iRow).Value)
		iRow += 1
	Loop

	oWB.Close()
	oWS = Nothing
	oWB = Nothing
	oExcel = Nothing
End Sub

Property sExcelFile As String = "PathExcelFile"
Public sNameSheet As String = "NameSheet"

Private Function GetExcel(Optional bVisible As Boolean = False) As Excel.Application
	Dim oXL As Microsoft.Office.Interop.Excel.Application
	Dim oObj As Object = Nothing
	Try
		oObj = GetObject(, "Excel.Application")
		oXL = TryCast(oObj, Microsoft.Office.Interop.Excel.Application)
	Catch
		oObj = CreateObject("Excel.Application")
		oXL = TryCast(oObj, Microsoft.Office.Interop.Excel.Application)
	End Try
	oObj = Nothing
	If oXL IsNot Nothing Then oXL.Visible = bVisible
	Return oXL
End Function

You need to specify the path to the file and the name of the sheet in the book (lines 21-22).

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature