I’m writing a simple script to count the number of referenced files giving a file in a vault of Solidworks PDM.
I get a Type mismatch error in GetFileFromPath method which has the following declaration for VBA:
Visual Basic (Declaration)
Function GetFileFromPath( _
ByVal bsFilePath As System.String, _
Optional ByRef ppoRetParentFolder As IEdmFolder5 _
) As IEdmFile5
This is the script:
Dim vault
Set vault = CreateObject(“ConisioLib.EdmVault”)
vault.LoginAuto “VaultName”, 0
If Not vault.IsLoggedIn Then
WScript.Echo “Impossible to login.”
Else
Dim filePath
filePath = “D:CompProjectsXYZABC.sldprt.cvd”
Dim file
Dim rootFolder
Set rootFolder = vault.RootFolder
**Set file = vault.GetFileFromPath(filePath, rootFolder)**
If Not file Is Nothing Then
Dim referenceTree
Set referenceTree = file.GetReferenceTree(0)
Dim childPosition
childPosition = referenceTree.GetFirstChildPosition("", 1, 1)
Dim numReferencedFiles
numReferencedFiles = 0
While Not childPosition.IsNull
numReferencedFiles = numReferencedFiles + 1
referenceTree.GetNextChild childPosition
Wend
WScript.Echo "Number of files referenced to file " & filePath & ": " & numReferencedFiles
Else
WScript.Echo "File doesn't exist in vault."
End If
End If
I tried to cast the filepath variabl with CStr, but I got the same error
Gianfranco Girardi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.