Result of a vba search on excel

Hello

I managed to launch a search (via VBA) on an EPDM vault via the snippet of code below.

My question is the following, I would like to retrieve in this search, the variables of each search results, I have, for example, a variable called _NumNDL.

I guess you have to use something like GetVar or eNumVar on one of the results, but I don't have the syntax or the solution. If anyone knows how to help me?

Sub FindFile()

Dim eVault          As IEdmVault5
Dim eSearch         As IEdmSearch5
Dim eResult         As IEdmSearchResult5
Dim FileCount       As Long

FileCount = 0

    'Connection to the trunk
    Set eVault = New EdmVault5
    eVault.LoginAuto eVault.GetVaultNameFromPath("C:\_Clarity\"), 0
    
    'Launch of the research
    Set eSearch = eVault.CreateSearch
    eSearch.AddVariable "_NDLNouv", "%1%"
    eSearch.Filename = "%NDL%"
    Set eResult = eSearch.GetFirstResult

    Reading the results
    While not eResult is nothing
        FileCount = FileCount + 1

        Cells(FileCount, 1) = eResult.Name
        Cells(FileCount, 2) = eResult.Path
        Cells(FileCount, 3) = eResult.StateName
        Set eResult = eSearch.GetNextResult
    Wend

End Sub

 

Hello

In fact, you can have an infinite number of results! So you can't use a variable, but you have to use an array, which is done here!

The line "  FileCount = FileCount + 1" is used to move to the next line.

And your data is stored in this way in 3 columns:

        Cells(FileCount, 1) = eResult.Name
        Cells(FileCount, 2) = eResult.Path
        Cells(FileCount, 3) = eResult.StateName

 

 

Thank you for your answer, but you give me a code that I wrote myself in response...

Sorry to contradict you, I may have expressed myself badly, but there are ePDM variables, if you look in the code I provided, I add the variable "_NDLnouv" to my search.

Via eResult, I can't retrieve all the search fields: 

 

I would like to be able to retrieve all the fields related to the search result.

Hello

Unless I'm mistaken, (I've already done this kind of macro), you have to extract the file to retrieve the content of the variable and then cancel the extraction.

So you need to add a complementary treatment.

See attached file for further processing


macro_search.txt
1 Like

Great thanks,

 

On the principle it works nice, suaf that I have an error on 424 on:

file. LockFile result. ParentFolderID, 0.

If I extract the file "by hand", it works, but I can't extract it via your code, I guess I'm missing the lockfile function?

I forgot to change, in both the lockfile and undolockfile functions you have to put  result. ParentFolderID instead of  result. ParentFolderID

Indeed, I missed it too, I could have checked it myself, in any case, it works niquel thank you very much.

However, in the state of mind, I find it strange that we are forced to go and extract the file because in the search display we can clearly see the different variables displayed and which are part of the search result. I'm surprised that you can't read them without going through lock or unlock.

Nevertheless, thank you for your help.

It's indeed strange, but from what I understood from the API help, it's related to the fact that variables are viewable via maps when they are editable. In fact, the files must be extracted.