1 Reply Latest reply on Feb 10, 2016 1:31 PM by Alice Caspari

    Insert a Named Table?

    Patrick Malone

      I want to insert a named table from a file location.

      Is this possible?

       

      I tried starting with a recording and it only inserts a generic table not the table I want to specify.

      Such as C:\TableFolder\Mytable.sldtbt

       

      This is what I have so far.....

       

      ==

       

      Dim swApp As Object

       

      Dim Part As Object

      Dim boolstatus As Boolean

      Dim longstatus As Long, longwarnings As Long

       

      Sub main()

       

      Set swApp = _

      Application.SldWorks

       

      Set Part = swApp.ActiveDoc

      Dim myTable As Object

      Set myTable = Part.InsertTableAnnotation(0.235053697247706, 0.327115880733945, 1, 7, 6)

      If Not myTable Is Nothing Then

         myTable.BorderLineWeight = 1

         myTable.GridLineWeight = 1

      End If

      End Sub

        • Re: Insert a Named Table?
          Alice Caspari

          What you have is to insert a blank general table.

          I'd try looking at the following method..

          2016 SOLIDWORKS API Help - InsertObjectFromFile Method (IModelDocExtension)

           

          This worked for me just put your path in the Path variable and specify your x,y,z position coordinates (currently 0,0,0)

           

          Option Explicit

           

          Dim swApp As Object

          Dim Part As Object

          Dim FilePath As String

          Dim Aspect As Integer

          Dim XPos As Double

          Dim YPos As Double

          Dim ZPos As Double

          Dim bool As Boolean

          Dim Path As String

           

          Sub main()

           

          Set swApp = Application.SldWorks

          Set Part = swApp.ActiveDoc

           

          Path = "C:\Users\casparia\Desktop\workflow.xlsx"

          bool = Part.InsertObjectFromFile(Path, 1, 0, 0, 0)

           

          End Sub