AnsweredAssumed Answered

How do I automatically import a design table from a excel file into solidworks using API

Question asked by Julian Veldhuijzen Van Zanten on Jul 3, 2013

EDIT: I found it. I needed to check the checkbox of Link to File in the feature of the design table and later check the box that asks permission to update the model from the updated xlsx file to no longer aks me this. As you can see, a really simple solution.

 

Dear Solidworks community,

 

For my internship I need to import an .xlsx (excel) file of a Design Table into a part. I can do this manually without any problems. I however want to automize this process and create a programm in Visual Basic 2010 express. So far the program starts solidworks, connects to it and opens the solidworks part. Yet, I can't find a way to import the .xlsx file automatically. I think it's a really easy command but I cannot get it done. When I record a macro it doesn't record the actions.

 

So my question is: "How do I make a Visual Basic 2010 express method for inserting a predefined .xlsx file from a predefined location to a already opened solidworks part?"

 

The manual command for this would be Insert->Tables->Design Table->Source:From file "C:\Users\J****\Documents\TESTFILE.xlsx". Then I don't change any options for the sake of simplicity. When the table is loaded I click next to the excel sheet to close it and Solidworks will generate the Design Table and it will give the message "Design table created for the parts : Big, Huge, Minimal".

 

So far my program looks like this:

 

 

Public Class MainForm

 

    Dim swApp As SldWorks.SldWorks   'connection to SolidWorks

    Dim part As SldWorks.ModelDoc2     'connection to SolidWorks current active part

 

'here are the other methods for opening the part etc.

 

         Private Sub EditmodelButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EditmodelButton.Click

               'Execute this method when pressing the 'Edit Model' button

 

             Dim DesignTable As Object

             Dim longstatus As Long

             swApp.ActivateDoc2("testfile.SLDPRT", False, longstatus)

             part = swApp.ActiveDoc

 

             DesignTable.InsertFamilyTableOpen("C:\Users\XXX\Documents\TESTFILE.xlsx")

 

    End Sub

End Class

 

This however does nothing. I hope someone could help me out .

 

P.S. Other methods that use the information from a excel sheet and puts in a existing design table is also good. As long as it does the trick

Outcomes