AnsweredAssumed Answered

PDMW Excel VBA Fails at CreateObject("PDMWorks.PDMWConnection")

Question asked by Sudheer Raju on Dec 8, 2016
Latest reply on Mar 11, 2017 by Tim Webb

Experts,

 

I am getting an error while running a MS Excel based Workgroup PDM VBA macro, which is to get the list of files stored in Workgroup PDM. This was working till last week, until we switched from SolidWorks 2015 to SolidWorks 2016.

The API at which is failing is while creating a connection object, Set connection = CreateObject("PDMWorks.PDMWConnection"). I get the below error message.

 

Macros_SW_PDMW_Error_01.PNG

When printing the Err.Number and Err.Description, it results in 429 & "ActiveX component can't create object".

 

I think I have the correct libraries imported, as below.

 

Macros_Tools_References_SW_PDMW.PNG

 

I have Googled enough to find a concrete solution for this, but couldn't fix this. Tried the below.

1. Registered pdmworks.dll using regsvr32.EXE "C:\Program Files\Common Files\SOLIDWORKS Shared\pdmworks.dll" command

2. Installed Document Manager API (SOLIDWORKS Document Manager API.msi)

3. I tried installing latest .NET framework

4. Visual Studio Tools for Applications 2015 and Visual Studio 2010 Tools for Office Runtime

5. I have the registry key HKEY_CLASSES_ROOT\CLSID\{A2529E35-C5ED-4FDA-B2CE-3AD8CC86850E} correctly, ProdID shows PDMWORKS.PDMWConnection.1 and the VersionIndependentProgID show PDMWORKS.PDMWConnection, as I see that is what CreateObject looks for

 

Below is my entire code.

 

Sub main()

 

    Dim n As Integer

    Dim first As Integer

    Dim second As Integer

    Dim myFile1 As String

    Dim myFile2 As String

    Dim k As Integer

    Dim i

    Dim fileCount

    Dim serverName As String

    Dim userName As String

    Dim password As String

    Dim projectName As String

    Dim connection As PDMWConnection

    Dim alldocs As PDMWDocuments

    Dim doc As PDMWDocument

    Dim project

    Dim item

    Dim options As PDMWorks.PDMWSearchOptions

    Dim criteria As PDMWorks.PDMWSearchCriteria

    Dim results As PDMWorks.PDMWSearchResults

    Dim result As PDMWorks.PDMWSearchResult

 

    Set connection = CreateObject("PDMWorks.PDMWConnection")

    connection.Login "userName", "password", "serverName"

    Debug.Print "1. connected to PDMW..."

 

    options.IgnoreCase = True

    options.SearchCriteria.AddCriteria pdmwOr, pdmwDocumentName, "All", pdmwContains, "sldprt"

    options.SearchCriteria.AddCriteria pdmwOr, pdmwDocumentName, "All", pdmwContains, "slddrw"

    options.SearchCriteria.AddCriteria pdmwOr, pdmwDocumentName, "All", pdmwContains, "sldasm"

 

    Set results = connection.Search(options)

    fileCount = results.Count

    Debug.Print "2. Search result count..." & fileCount

 

    connection.Logout

 

    MsgBox "Macro complete..."

   

End Sub

 

 

Your help is highly appreciated.

 

--

Sudheer

Outcomes