You need to go through the design hierarchy once to build a map of refdes to component id - keep in mind that there will be multi-gate devices where the same refdes is used on multiple instances.
Once you have the UID, you can call the SelectPath method. See Reference Designator Assignment based on schematic location for an example of how to do both.
I looked at the 2 efms and 1 vbs but couldn't find SelectPath usage.
Can you please explain why we need to build a map of refdes to component id - how does that help? Secondly, SelectPath method utilizes the hierarchical path so does that mean that for a component that's at a lower level in hierarchy, it's hierarchical path is composed of block (name) and it's uid?
Sorry, I did not use SelectPath, I used PushPath, inside this function that is called when you double-click a row:
Function SelectHierarchicalPath(sTopBlockName, sFullPath)
iLastColon = InStr(sFullPath, ":")
iLastSlash = InStrRev(sFullPath, "\")
If iLastSlash > 0 Then
sPath = Mid(sFullPath, 1, iLastSlash - 1)
sUID = Mid(sFullPath, iLastSlash + 1, iLastColon - iLastSlash - 1)
sPath = ""
sUID = Mid(sFullPath, 1, iLastColon - 1)
sSheet = Mid(sFullPath, iLastColon + 1)
PushPath sTopBlockName, sPath, sSheet
ExecuteCommand "sname " & sUID
If you look at the other code in this efm file, you will see the full path is built up with the hierarchical path, followed by the uid, followed by the sheet number.
There is no way to search the whole design for a particular reference designator through automation, that is why you need to build this map of refdes to uid & sheet.