You want to define objects in your AUT using code and also add them to OR? Don't you think this is extra work?
I don't want to stop you from doing it but if you are using code to write descriptions for objects, then I don't see a reason why you would need to add them to OR. You can simply record on the objects that you want in OR and modify them as per their behavior.
Set Repository1 = CreateObject("Mercury.ObjectRepositoryUtil")
Set Repository2 = CreateObject("Mercury.ObjectRepositoryUtil")
Set WinLogin = Repository1.GetObject("Dialog(""Login"")")
Repository2.AddObject WinLogin, Null
By using this code I am trying to go step by step to my goal. In this code I've one object Dialog("Login") in OR_old.tsr and 1OR_new.tsr is blank. I am trying to add that object from OR_old to 1OR_New but QTP is stopping the execution at following line without any error Repository2.AddObject WinLogin, Null
and If I execute the same script again then while loading the 1OR_new.tsr it is throwing a general load error.
I guess the file 1OR_new got corrupted whil executing AddObject statement. Please correct me If I am doing anything wrong.