8 Replies Latest reply on Dec 29, 2015 8:57 AM by Fabrizio Todaro

    Document Manager API in VBA

    Nirantar Vidyarthee

      It seems that the Document Manager API can not be used in VBA.

      Am I right or I am missing something?

        • Re: Document Manager API in VBA
          Deepak Gupta

          AFAIK, it can not be used with VBA

          • Re: Document Manager API in VBA
            Josh Brady

            Yes, it can certainly be used with VBA, although you need a license key string.  This can be obtained from apisupport@solidworks.com.  However, it's for internal use only.  You can't distribute outside your company.

             

            Edit: Email method is old!. Now you get at this link:

            http://www.solidworks.com/sw/support/api-support.htm

             

            • Re: Document Manager API in VBA
              Michael Spens

              FYI, I'll be doing a break-out session at SWW 2016 focused on the Document Manager.  If you'll be at SWW, please come!  Currently scheduled for Monday at 2:45pm. I'm planning on covering these topics...

              • Custom property extraction/manipulation
              • BOM/Table extraction
              • Reference reporting/repairing
                • Re: Document Manager API in VBA
                  Josh Brady

                  That should be super useful!

                   

                  On a slightly related note, do you have any info on the history etc of document manager API?  I'm particularly curious:

                   

                  1. Why you need a license key

                  2. Why access was changed to open for one release of SW ('08 maybe? I forget)

                  3. Why it was locked back down

                  4. Why it's now locked down even further to where you have to specify the extent of functionality

                   

                  I'm sure there are reasons, but I've never really seen them explained.  With no explanation it just seems like stupid hoops to jump through to get access to useful tools.

                    • Re: Document Manager API in VBA
                      Michael Spens

                      Hey Josh,

                       

                      Hopefully these will help...

                      1. The license key requirement is to help us control who is utilizing the Document Manager and how.
                      2. Not sure I completely understand the question, but the DM key is now for one release, starting with 2015.  Your key will allow you to work with files of that release and older, just like in the SOLIDWORKS UI.
                      3. & 4.  The locking and itemizing of the DM license was done to give us better control of what partners can access.  I realize it makes it a little more challenging for customers, but hopefully you'll find the license key request process fast and effective now.
                        • Re: Document Manager API in VBA
                          Josh Brady

                          I can't find the documentation now (it may have even been expunged), but for 2007 the requirement for the key was removed.  Document manger API was wide open, which I thought was a good thing.  Then it snapped back shut on one of the service packs.

                           

                          I guess I don't really see what's being protected if you give away keys to whoever asks.  You may be able to see who can come in the door, but how they got there, what they're bringing, and what they do once they get in are still wide open, right?

                    • Re: Document Manager API in VBA
                      Fabrizio Todaro

                      Hello Nirantar Vidyarthee,

                      I use this routine in SolidWorks 2016 to get custom property without load files.

                       

                       

                      Function Get_Props()

                      Dim swapp As SldWorks.SldWorks
                      Dim f As SwDMClassFactory
                      Set swapp = Application.SldWorks
                      Dim p As stdole.StdPicture

                      If UserForm1.TextBox2.Text = "File non Esistente" Then Exit Function
                      If Disegno.Value = True Then Exit Function
                      If Dwg.Value = True Then Exit Function

                      Set f = New SwDMClassFactory

                      Dim swCfg As SwDMConfiguration14
                      Dim swCfgMgr As SwDMConfigurationMgr
                      Dim vCfgNameArr As Variant
                      Dim vCfgName As Variant

                      Dim a As SwDMApplication
                      Set a = f.GetApplication("***********Your serial***********")

                      Dim d As ISwDMDocument3
                      Dim d2 As ISwDMDocument17
                      Dim e As SwDmDocumentOpenError
                      Dim path As String

                      path = swapp.GetExecutablePath
                      'Debug.Print UserForm1.TextBox2.Text
                      'File_con_Path = UserForm1.TextBox2.Text
                      'Debug.Print "File_con_Path: "; File_con_Path

                      Set d = a.GetDocument(File_con_Path, 1, True, e)
                      Set d2 = a.GetDocument(File_con_Path, 1, True, e)

                      On Error GoTo Whoa

                      Set swCfgMgr = d2.ConfigurationManager

                      Dim Descrizione As String

                      vCfgNameArr = swCfgMgr.GetConfigurationNames

                                  Set swCfg = swCfgMgr.GetConfigurationByName(vCfgNameArr(0))
                                      
                                      Description = swCfg.GetCustomProperty2("Description", swDmCustomInfoText)
                                      Autor = swCfg.GetCustomProperty2("Autor", swDmCustomInfoText)
                                      Date = swCfg.GetCustomProperty2("Date", swDmCustomInfoText)

                                 
                                      Debug.Print "Description: "; Description
                                      Debug.Print "Autor: "; Autor
                                      Debug.Print "Date: "; Date               

                      Whoa:
                      Debug.Print Error

                      End Function