11 Replies Latest reply on Apr 17, 2018 12:50 PM by Milan Wendl

    Problem with: swClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory") in SW2018 SP2

    Milan Wendl

      Hello My SolidWorks Colleagues,

      Today I did finally switched to SW 2018 SP2 from 2017 SP4.1 and I am getting unexpected problem with the following line of code which I was using for the many years for number of VBA functions without problem.

       

      Dim swClassFact As SwDocumentMgr.SwDMClassFactory

      Set swClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory")

       

      This line is giving me the error 429 ActiveX component can't create object. SwDocumentMgr.dll is registered and referenced.

      I hope somebody has the solution for me.

       

      Thank you very much.

       

      Milan.

        • Re: Problem with: swClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory") in SW2018 SP2
          Alastair Cardwell

          Did you update your Document Manager API licence key for SolidWorks 2018? As of the last couple of versions you need a new key for each new version of SolidWorks.

           

          You can request a new key by logging into the customer portal and going to API help where you will find a link for Document Manager Key Request.

           

          Alastair

          • Re: Problem with: swClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory") in SW2018 SP2
            Artem Taturevych

            Can you check in your registry if you have this com object in there?

              • Re: Problem with: swClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory") in SW2018 SP2
                Milan Wendl

                Hello Alastair and Artem,

                Thanks for your response. Please find the following code:

                 

                Public Function SWGetExternalReferences1(FPath As String, intLevel As Integer, intItemCount As Integer) As Variant
                On Error GoTo Err_Handler

                    Dim intSWItem As Integer
                   
                    Dim swClassFact     As SwDocumentMgr.SwDMClassFactory
                    Dim swDocMgr        As SwDocumentMgr.SwDMApplication
                    Dim SwDMDocument14  As SwDocumentMgr.SwDMDocument14
                    Dim swSearchOpt     As SwDocumentMgr.SwDMSearchOption
                    Dim IsVirtual       As Object
                    Dim TimeStamp       As Object
                    Dim nDocType        As Long
                    Dim nRetval         As Long
                    Dim vDependArr      As Variant
                    Dim vDepend         As Variant
                    Dim bRet            As Boolean

                    '== Determine type of SolidWorks file based on file extension
                    If InStr(LCase(FPath), "sldprt") > 0 Then
                        nDocType = swDmDocumentPart
                    ElseIf InStr(LCase(FPath), "sldasm") > 0 Then
                        nDocType = swDmDocumentAssembly
                    ElseIf InStr(LCase(FPath), "slddrw") > 0 Then
                        nDocType = swDmDocumentDrawing
                    Else
                        'Probably not a SolidWorks file
                        nDocType = swDmDocumentUnknown
                        'So cannot open
                        Exit Function
                    End If

                  

                     Set swClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory")    '===== Error 'ActiveX component can't create object' in this line with SW2018 SP2
                   
                    If GetSWVersion = "2018" Then
                        Set swDocMgr = swClassFact.GetApplication(sSWLicenseKey2018)
                    ElseIf GetSWVersion = "2017" Then
                        Set swDocMgr = swClassFact.GetApplication(sSWLicenseKey2017)
                    ElseIf GetSWVersion = "2016" Then
                        Set swDocMgr = swClassFact.GetApplication(sSWLicenseKey2016)
                    ElseIf GetSWVersion = "2015" Then
                        Set swDocMgr = swClassFact.GetApplication(sSWLicenseKey2015)
                    ElseIf GetSWVersion <= "2014" Then
                        Set swDocMgr = swClassFact.GetApplication(sSWLicenseKey2014)
                    End If
                    Set swSearchOpt = swDocMgr.GetSearchOptionObject

                 

                1. Alastair, Document Manager License Key, which I have received in March, kicks in after the line with error. Its accuracy, if it is the case, should not have the influence.

                2. Artem, after removing previous SolidWorks and before installing a new version, I typically use CCleaner for the registry cleaning. This type I did same, but downloaded as well Javelin paper on uninstalling SolidWorks, where I did follow their notes and removed manually some other registry keys.

                I have in program the following SW related registered references, which were standard and enough for many years in what I am doing with code:

                C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\sldworks.tlb

                C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\swconst.tlb

                C:\Program Files\Common Files\SOLIDWORKS Shared\swdocumentmgr.dll

                These are naturally from SW2018.

                Artem, sorry but I do not 100% know what do you mean when you say: check in your registry if you have this com object in there.

                I've just noticed that on your notes to me it shows 'Correct Answer'.

                 

                My problem is not fixed.

                Thanks,

                Milan.