Deleting attachment from UI and replacing with file name or other text

Is there a way to automatically remove an attachment from a UI document and then place a link (or text) into the document where the attachment once “stood”?

I know something similar is done when you delete an attachment from a UI document, but this requires several steps (right click, select).

Is there a way to do this programatically so that the user picks an attachment name from a list (perhaps presented after pressing a button) and then the attachment is removed and replaced with text or a link? In fact, a list may not even be required, as processing for all attachments would be welcome.