I am trying to incorporate some code to an excel VBA macro that will do a PDM search for a variable that's already defined and then get the latest version of that file.
Any help is greatly appreciated. Thanks Eric
2016 SOLIDWORKS API Help - GetFileCopy Method (IEdmEnumeratorVersion5)
This should get you pointed in the right direction:
Thanks for the info. Does anyone have an example of these operations in VBA?
I am also trying to figure out a way to search PDM inside of Excel using VBA. Have you found a solution?
I was able to write the code to search and find the file based on the variable, but I never found code to "get latest version"
Hello Eric, i'm interested to know your code "to search and find the file based on the variable"
Dim eVault As IEdmVault5
Dim eSearch As IEdmSearch5
Dim eResult As IEdmSearchResult5
Dim eFolder As IEdmFolder5
Dim eName As IEdmObject5
Dim eCardaccess As IEdmEnumeratorVariable5
Dim vaultname As String
Dim FileName As String
vaultname = ("your vault name here") 'vault name
Set eVault = New EdmVault5
If Not eVault.IsLoggedIn Then 'log into vault
Call eVault.LoginAuto(vaultname, 0)
Set eSearch = eVault.CreateSearch 'set search
eSearch.FindFiles = True
eSearch.FindUnlockedFiles = True
eSearch.FindLockedFiles = True
eSearch.Recursive = True
FileName = "value you want to search"
eSearch.AddVariable "Part Number", FileName 'variable searching for and value
Set eResult = eSearch.GetFirstResult 'results of search
I know this is a old thread but this may help someone in the future.
Here's an c# example, I check out the file and do a undo checkout. You may want to do a check if the file was actually checked out before undo checking out, may cause problems if the file size is big or network is slow.
Retrieving data ...