Option Explicit
Option Base 1
Sub Main()
'SolidWorks Objects
Dim swApp As Object
Dim Part As Object
'Excel Objects
Dim xlApp As Object
Dim wb As Workbook
Dim ws As Worksheet
Dim iRow As Long
Dim ptX() As Long, ptY() As Long
Dim sMsg As String
'Attach to Solidworks
Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
'Open Excel and the Data Workbook
Set xlApp = CreateObject("Excel.Application")
Workbooks.Open FileName:="C:\Data.xls", ReadOnly:=True
Workbooks.Application.Visible = True
Set wb = xlApp.ActiveWorkbook
Set ws = wb.Sheets("Sheet1")
'Extract the data (X in col A, Y in Col B)
iRow = 1 'first row of data
Do While Len(ws.Range("A" & iRow).Text) > 0
ReDim Preserve ptX(iRow)
ReDim Preserve ptY(iRow)
ptX(iRow) = ws.Range("A" & iRow).Value
ptY(iRow) = ws.Range("B" & iRow).Value
iRow = iRow + 1
Loop
'Close Excel
xlApp.Quit
'Report the info back to the user
For iRow = LBound(ptX) To UBound(ptX)
sMsg = sMsg & "Point " & iRow & ": (" & ptX(iRow) & ", " & ptY(iRow) & ")" & vbCrLf
Next iRow
swApp.SendMsgToUser sMsg
Set ws = Nothing
Set wb = Nothing
Set xlApp = Nothing
Set Part = Nothing
Set swApp = Nothing
End Sub