6 Replies Latest reply on Sep 19, 2014 8:02 AM by Thomas Granzow

    VBA runtime error when using PDM checkIn function

    Thomas Granzow

      So im trying to write a makro to automate the name generation and the check in to the pdm Vault. The makro works fine to the point where the checkIn function is used.

       

      I get the runtime error´-2147220968 (80040218)

      There is no valid client license on this machine

       

      The manual check in works fine and i can delete files from the fault via API.

        • Re: VBA runtime error when using PDM checkIn function
          Deepak Gupta

          Kindly share the complete macro OR codes to debug.

            • Re: VBA runtime error when using PDM checkIn function
              Thomas Granzow

              Dim myPDMConn As New PDMWorks.PDMWConnection

               

              Dim myProperty As PDMWorks.PDMWProperties

               

              Dim myProperties As IPDMWProperties

               

              Dim myPDMWSearchOptions As PDMWorks.PDMWSearchOptions

               

              Dim mySearchCriteria As PDMWorks.PDMWSearchCriteria

               

              Dim results As PDMWorks.PDMWSearchResults

               

              Dim result As PDMWorks.PDMWSearchResult

               

              Dim andOr As PDMWorks.PDMWAndOr

               

              Dim propertyTypeName As PDMWPropertyType

               

              Dim propertyTypeRev As PDMWPropertyType

               

              Dim condition As PDMWConditionType

               

              Dim myDoc As PDMWDocument

               

              'Testbereich-------------------------------------------------------------------

              Dim slwLink As Object

              Dim currentPart As Object

              Dim longstatus As LongLong, longwarnings As LongLong

              Dim saveOptions As swSaveAsOptions_e

              Dim saveErrors As swFileSaveError_e

              Dim saveWarnings As swFileSaveWarning_e

               

              Dim filename As String

              Dim project As String

              'Dim partNumber As String

              'Dim Description As String

              'Dim note As String

              Dim i_revOption As PDMWRevisionOptionType

              'Dim Revision As String

              'Dim lifecycle As String

              Dim RetainOwnership As Boolean

              'Dim References As Object

              Dim checkInReturnValue As PDMWorks.PDMWDocument

              Dim returnValueDelete As Integer

              Dim deleteString As String

               

              Dim value As Long

              Dim valueCount As Long

              Dim hey As String

              '------------------------------------------------------------------------------

               

              Dim Number As Long

               

              Dim cnt As Long

               

              Dim strDocName As String

               

               

              Sub Main()

               

              'Variablendeklaration-------------------------------------------------------------------

               

                  andOr = pdmwAnd

                 

                  propertyTypeName = pdmwDocumentName

                 

                  propertyTypeRev = pdmwRevision

                 

                  condition = pdmwContains

                 

                  saveOptions = swSaveAsOptions_Silent

                 

                  saveErrors = swFileNameEmpty

                 

                  saveWarnings = swFileSaveWarning_NeedsRebuild

                 

                  i_recOption = Default

               

               

                  Set slwLink = Application.SldWorks

                 

                  Set currentPart = slwLink.ActiveDoc

                     

                  Set myPDMConn = CreateObject("PDMWorks.PDMWConnection")

                 

              'Verbindungsaufbau zum Tresor-------------------------------------------------------------------

                 

                  myPDMConn.Login "admin", "adminPW", "server"

                 

                  myPDMConn.Refresh

               

              'Suchoptionen-------------------------------------------------------------------

                 

                  Set myPDMWSearchOptions = myPDMConn.GetSearchOptionsObject

                 

                 

                  If Not myPDMWSearchOptions Is Nothing Then

               

                      myPDMWSearchOptions.IgnoreCase = True

               

                      myPDMWSearchOptions.IgnoreLinks = False

               

                      myPDMWSearchOptions.IncludeHiddenDocuments = True

               

                      myPDMWSearchOptions.SearchConfigSpecificProperties = False

               

                      myPDMWSearchOptions.SearchOnlyChildrenOf = ""

                      

                     

                      myPDMWSearchOptions.SearchCriteria.AddCriteria andOr, propertyTypeName, "", condition, "sldprt"

               

                      myPDMWSearchOptions.SearchCriteria.AddCriteria andOr, propertyTypeRev, "", condition, "00"

                     

               

                      myPDMWSearchOptions.SearchCriteria.SaveToFile "P:\MedFact Standard Blattformate\Makros\cri_test.sqy"

               

                      myPDMWSearchOptions.SearchCriteria.LoadFromFile "P:\MedFact Standard Blattformate\Makros\cri_test.sqy"

                     

              'Erhalten und auswerten der Ergebnisse-------------------------------------------------------------------

               

                  myPDMConn.Refresh

               

                      Set results = myPDMConn.Search(myPDMWSearchOptions)

               

                      If Not results Is Nothing Then

               

                          cnt = results.Count

                          

                      End If

                     

              'Speichername mit Counter zuweisen und Dokument schließen-------------------------------------------------------------------

                     

                      cnt = cnt + 1

                     

                      filename = "P:\Endodrill II\" & cnt & ".SLDPRT"

                     

                      longstatus = currentPart.Extension.SaveAs(filename, 0, saveOptions, Nothing, saveErrors, saveWarnings)

                     

                      slwLink.QuitDoc currentPart.GetTitle

               

              'Einchecken in die Vault-------------------------------------------------------------------

               

                      'deleteString = cnt & ".SLDPRT"

               

                      myPDMConn.Refresh

                     

                      'returnValueDelete = myPDMConn.DeleteDocument(deleteString)

                             

                      Set checkInReturnValue = myPDMConn.CheckIn(filename, "sample", "1001", "sample prt", "Check in via API", PDMWRevisionOptionType.Default, "00", "WIP", False, Nothing)

               

                  End If

               

                  myPDMConn.Logout

               

              End Sub

            • Re: VBA runtime error when using PDM checkIn function
              Santosh Pawar

              Hi Thomas,

               

              Modify the path environment variable to include C:\Program Files\Common Files\SolidWorks Shared, restart the machine.

               

              Take a look at the pdf attached to last post at following link for details,

              https://forum.solidworks.com/message/213534?sr=search&searchId=ac009a42-d82d-4007-a1ff-cc5c93a100b7&searchIndex=1#213534