cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to transform Keyword to Definition via a macro

sgonthey
Super Contributor

hello,

I need some help to write  a macro to do a laborious work
Here is my problem.
I  have  some keywords that I Want to transform to Defition objects.

So I have to :
- Create my list of  keywords via  a request ==> OK
- Catch the name and the comment  of each keyword==> OK
- Create an object "Term" with the name of the  Keyword==> OK
- Put the comment of the Keyword in the comment of the term==> OK
- Create  a definition and attach the previous created term with it, because it's not possible  to create directly a Definition ( Without Terme)
- Unbind all the objects of the keyword, and link these objects  with the new definition.

Thanks a lot  for your help !

 

Sandrine

 

My code :

Set oRoot = MegaRoot
Set oMotCleColl = oRoot.getSelection("Select [Mot-Clé] Where [Dossier parent].[Nom court] =""....."")
Set oTermes = oRoot.getcollection("Terme")
Set oDefTermes= oTermes.Item("Définition")
For Each oMotCle in oMotCleColl
        oKWComment =oMotCle.GetProp("Comment","object")
      oKWName =oMotCle.Name
    oTermes.Create oKWName         
       For Each oTerme in oTermes    
            if oTerme.Name=oKWName  then
             oTerme.setProp("Commentaire")=oKWComment
            End If
        Next
Next

3 Replies

Oups... Sorry for the "Severine"... Smiley Embarassed

sgonthey
Super Contributor

Thanks a lot  for the response .

It works perfectly .

 

Bye

 

Sandrine

 

lionel
MEGA
MEGA

Hello Severine,

 

the following code should work if I understand what you want to do :

 

Set oRoot = MegaRoot
Set oMotCleColl = oRoot.getCollection("mot-clé")
For Each oMotCle in oMotCleColl
	oKWComment =oMotCle.GetProp("Comment","object")
	oKWName =oMotCle.Name

	Set objFrancais = getObjectFromId("~B0SNPuLckCQ3[Francais]") 'French language in your case
	Set oNewTerme = objFrancais.getCollection("~WeGnj1jw4PE0[Terme]").Add(oKWName)
	Set oNewDef = oNewTerme.getCollection("Définition").Create(oKWName) 
	oNewDef.setProp("Commentaire")=oKWComment

	Set colDefObjects = oNewDef.getCollection("Objet Défini")
	For each myObj in oMotCle.getCollection("Elément avec mot-clé")
		Set myNewObjDefinition = colDefObjects.Add(myObj)
	Next
Next

 

Regards,

 

Lionel