New topic: Opening a file with a non-default application
<http://forums.realsoftware.com/viewtopic.php?t=39313> Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message Pengwin Post subject: Opening a file with a non-default applicationPosted: Sat Jun 04, 2011 12:33 pm Joined: Fri Mar 03, 2006 5:57 pm Posts: 35 Location: Elgin, Scotland I have worked on a couple of projects which have required me to designate an application to open a file and in some circumstances, this is not the default application. Therefore, I came up with a small routine to do this (only Mac and Windows I'm afraid) Code:Sub OpenFileWith(DocumentPath As FolderItem, ApplicationPath As FolderItem) Dim ShellString As String Dim sh As Shell=New Shell #if TargetMacOS ShellString="open -a '" + ApplicationPath.ShellPath + "' '" + DocumentPath.ShellPath + "'" #elseif TargetWin32 ShellString=ApplicationPath.AbsolutePath + " " + DocumentPath.AbsolutePath #endif sh.Execute(ShellString) End Sub On a Mac, it also appears that you can open the application by just using its name, so this can also be addressed by the overriding the subroutine with the following: Code:Sub OpenFileWith(DocumentPath As FolderItem, ApplicationName As String) #if TargetMacOS Dim ShellString As String Dim sh As Shell=New Shell ShellString="open -a '" + ApplicationName + "' '" + DocumentPath.ShellPath + "'" sh.Execute(ShellString) #endif End Sub Hope this helps anyone else who needs to do something like this. _________________ Mark [Real Studio 2011 Pro on OSX 10.5 targeting OSX and Windows] Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 1 post ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml rbforumnotifier@monkeybreadsoftware.de