2 Replies Latest reply on Oct 9, 2015 6:26 AM by Ivana Kolin

    Any way to get part/assembly custom properties into Excel?

    Ari Arponen

      Ok, I need some way to get for example "Description" custom property from part file into Excel sheet from a specific folder. Basicly I need lines like this into Excel:

       

      "filename"     "Description"     "Description2" ... etc properties.

       

      What I need is a "catalogue" of all the parts in specific folder. What would be the best way to do this?

        • Re: Any way to get part/assembly custom properties into Excel?
          Peter Brinkhuis

          Because you've posted in the API section, I think you already imagined that you would need a macro. I think you're right The start would be be something like this. I've copied most of it from a macro of mine and changed some stuff, so I hope it works.

           

          Option Explicit

           

          'Global variables

          Dim swApp As SldWorks.SldWorks

          Dim swModel As SldWorks.ModelDoc2

           

          Sub main()

           

          Set swApp = Application.SldWorks

          Dim sFilelocation As String

           

          'Select a folder

          call selectfolder(sFileLocation)

           

          'Now you have to open the files one by one, and in that loop:

               Set swModel = swApp.ActiveDoc

           

          Function selectfolder(byref sFileLocation )

              Dim objShell As New Shell32.Shell

              Dim objFolder As Shell32.Folder

              Dim sFilelocation As String

           

              'If you use 16384 instead of 1 on the next line,files are also displayed

              Set objFolder = objShell.BrowseForFolder(0, "Choose destination folder", 1)

             

              If Not objFolder Is Nothing Then

                  'Store the path

                  sFilelocation = objFolder.Items.Item.Path

              End If

          End Function

          To get the folder function running, you need to add "Microsoft scripting runtime" to your macro's reference list.