Your code appears to assume that the rich text element it finds at the current position is going to be a doclink. I’m guessing that’s where your code goes wrong, but without more detail it is just a guess – for example, for all I know your script can’t even create the navigator object. What about the debugger?
Also, what’s “result”? Are you sure it’s instantiated? As expressed in your script it’s a variable, but if you’re looking to actually find a field called “result” then your code is wrong. It should read:
Set rti = doc.GetFirstItem("result")
Set rtnav = rti.CreateNavigator
In this form I have several rich text fields (result1, result2, …, result8) some of them can have or not doclinks.
In this example and when I am debugging, the first field “result1” have a doclink and an attachment. Attachment name is printed but an error appears “position is not valid” when it reaches the code for doclink, I can send you all code if you need.