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.


Categories: API∕Macros

Comments
Last comment By: Milan Wendl   Tue, 17 Apr 2018 16:50:12 GMT
Re: Problem with: swClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory") in SW2018 SP2

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

By: Alastair Cardwell  Mon, 16 Apr 2018 07:04:33 GMT
Re: Problem with: swClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory") in SW2018 SP2

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

By: Artem Taturevych  Mon, 16 Apr 2018 10:50:55 GMT
Re: Problem with: swClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory") in SW2018 SP2

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.

By: Milan Wendl  Mon, 16 Apr 2018 15:20:41 GMT
Re: Problem with: swClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory") in SW2018 SP2

from your error i can guarantee that you cannot call createobject because the registry is not correct.

the error you have is exactly what happens when createobject is called on a non registered DLL.

 

CreateObject requires that the COM Class is registered in the registry as Artem Taturevych stated.

 

it should be in Registry Class Root

Computer\HKEY_CLASSES_ROOT\SwDocumentMgr.SwDMClassFactory (maybe .1 or .2 or .3....)

 

in there is the classid

 

Computer\HKEY_CLASSES_ROOT\SwDocumentMgr.SwDMClassFactory.1\CLSID

which takes us to

Computer\HKEY_CLASSES_ROOT\CLSID\{00AB5D8D-2B8F-416b-9761-92FACC8872BE}

in there is the data that CreateObject requires.

 

if it is not there than you cannot create it. simple as that.

 

what we find here is the location of the DLL

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

By: Jacob Corder  Mon, 16 Apr 2018 15:55:16 GMT
Re: Problem with: swClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory") in SW2018 SP2

Hello Jacob, thank for your help.

I have checked my registry and I did find the following:

Registry 1.JPG

There is this part above, which has in CLSID the same value as one with .1 bellow.

I have compared registry of my production desktop with the old one with SW2017 which runs fine, it the same.

Kindly any other idea please?

Thanks,

Milan.

By: Milan Wendl  Mon, 16 Apr 2018 17:08:57 GMT
Re: Problem with: swClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory") in SW2018 SP2

per my instructions above.  i said to then go to this location

 

Computer\HKEY_CLASSES_ROOT\CLSID\{00AB5D8D-2B8F-416b-9761-92FACC8872BE}

 

does this one exist?

 

one other way to see what is wrong is to download ProcessMonitor from sysinternals.

 

it will show you what registry keys are being accessed and what ones it cannot find.

 

FYI

CreateObject first looks in the GAC for DLL files.

the second place is using Side By Side which means if it is  in the same directory as the executing application is, then it will use that .DLL. 

last place is the registry in the directories i showed you.

By: Jacob Corder  Mon, 16 Apr 2018 17:50:01 GMT
Re: Problem with: swClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory") in SW2018 SP2

Hello Jacob, Artem and Alastair,

My registry is clean, with appropriate entries Jacob talked about.

I am using 32-bt MS Access and wonder if this is the problem.

Looked around this forum and noticed the thread with the following answer :

 

by Jess Darres on 1-Mar-2018 4:40 AM

SwDocumentMgr.dll (2018) is working for 64-bit application only. It won't support the 32-bit application.

 

I wonder if it relates to my problem.

 

Milan.

By: Milan Wendl  Mon, 16 Apr 2018 23:54:47 GMT
Re: Problem with: swClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory") in SW2018 SP2

Are you running this macro from Access? If so, than you are right about the issue. If you are running this from SOLIDWORKS than this is a 64 bit process and should work.

By: Artem Taturevych  Tue, 17 Apr 2018 06:08:38 GMT
Re: Problem with: swClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory") in SW2018 SP2

If Your application is 32-bit, it won't support. SwDocumentMgr.dlll (SW 2018) support only 64-bit application, So better to change your source application from 32 to 64-bit.

By: Jess Darres  Tue, 17 Apr 2018 06:23:15 GMT
Re: Problem with: swClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory") in SW2018 SP2

This is why it is important to always add as much information  as you can when asking for help.

By: Jacob Corder  Tue, 17 Apr 2018 16:19:18 GMT
Re: Problem with: swClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory") in SW2018 SP2

Hello my helping friends,

Thank you for you time and help. That 64-bit only change should be clearly notified at installation of SW 2018, but these decisions are not made by engineers or programmers unfortunately in our world!

I am back on SW2017 SP5 for time being. I do not have much time now to convert my 32 bit AAA ERP program (with full accounting, time tracking etc.), which I am working for over 20 years. It is not going to be big deal except the automated file preview, which will give me a longer time to convert. Please have a look at its screen shoot in attachment. I am on continuous maintenance with Solid Edge since about 1996 and with SolidWorks Premium since 2006.

Thanks again.

Milan Wendl, MEngSc, P.Eng.

AAA Engineering, Toronto, Canada

AAA ERP.png

By: Milan Wendl  Tue, 17 Apr 2018 16:50:12 GMT
You are not authorized to view this page No results found! Suggestions: Check spelling, try a different search, or browse topics below.