AnsweredAssumed Answered

how to import values from excel file

Question asked by Vishaldeep Singh on Apr 3, 2014
Latest reply on Apr 10, 2014 by Jesse Seger

hello

i want to take the co-ordinates values of a point from excel file and take the values untill blank row comes.

 

i was trying one code but there is some error i am writin the code below can any one debug it.

the code will run only when the excel file is open.

 

 

'''''' code'''''''

Dim swApp As Object

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim Excel As Object

Dim i As Integer

Dim xpt As Double

Dim ypt As Double

Dim zpt As Double

Sub main()

 

 

Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

 

 

            Excel = GetObject(, "Excel.Application")

            swModel = CType(swApp.ActiveDoc, ModelDoc2)

            swModel.SketchManager.Insert3DSketch (True)

            Dim skPoint As SketchPoint

            swModel.SketchManager.AddToDB = True

 

 

        Do While Excel.cells(i, 1).Text <> ""

 

 

            xpt = Excel.cells(i, 1).Value

            ypt = Excel.cells(i, 2).Value

            zpt = Excel.cells(i, 3).Value

            skPoint = swModel.SketchManager.CreatePoint(xpt, ypt, zpt)

            i = i + 1

 

 

        Loop

        swModel.SketchManager.InsertSketch (True)

        swModel.SketchManager.AddToDB = False

End Sub

Outcomes