Reveal a FolderItem in the Finder With an Apple Event

Use Apple events to tell the Finder to show a FolderItem.

Sub ShowInFinder(f as FolderItem)
    if f is nil or not f.Exists then
    end if
    dim slct as new AppleEvent("misc", "slct", "")
    slct.FolderItemParam("----") = f
    If slct.send then
        dim actv as new AppleEvent("misc", "actv", "")
        If actv.send then
            //activate failed
        end if
        //select failed
    end if
End Sub

The first Apple event directs the Finder to select the passed FolderItem; the folder containing the FolderItem will also open. The second Apple event tells the Finder to come to the front.

2015-01-20: the code example is updated for recent Xojo versions.