I don’t have Internet Explorer installed so I can’t test your script, but you could bypass the problem by using “open location” from the Standard Additions dictionary. It should work with any browser.
set appname to "Firefox"
set webaddr to "http://www.google.com"
tell application appname to open location webaddr
Because the AppleScript compiler pulls all sorts of sneaky tricks to support those fancy “English-like” keywords we all know and love. Chief amongst these tricks is looking for ‘tell application “…”’ lines so it knows what application-specific keywords to look for when compiling statements within the tell block.
Mostly this works well enough for simple code, but once you push the language a bit harder such clever-cleverness can start to bite you instead. Because your script doesn’t provide the application name till runtime, the compiler doesn’t know to look up additional terminology so makes do with only those keywords defined in AppleScript and any loaded osaxen. And ‘GetURL’ is not amongst these default keywords, as you’ve discovered.
There are a few options open to you:
Use the raw Apple event code in place of the ‘GetURL’ keyword; in this case «event GURLGURL».
Enclose the relevant code in a ‘using terms from application “Internet Explorer”’ block. This explicitly informs the compiler where to obtain additional terminology from when compiling the enclosed code.
Standard Additions also happens to define a keyword for this particular event, ‘open location’, which you can use in place of ‘GetURL’. (Standard Additions also defines its own «event GURLGURL» handler that opens the URL in the system’s default browser, but as long as your target applications define their own «event GURLGURL» handlers they’ll handle it themselves.)
Are you noting the errors returned? Are you also Looking in the “events” window to see whas happening? Those two things give your answer:
A prompt showed me the error and took me to edit, where “GetURL webaddr” was highlighted. As Esme pointed out above, the correct syntex for IE is “open location”. Got that to work, but IE would open and then close. So I watched the events window-the “Launch” command was causing a problem. Scrap that. What I was left with launched Google from a variable with IE as a variable, “SurfApp”
set SurfApp to "Internet Explorer"
set UrlVar to "http://www.google.com" as string
tell application SurfApp
open location UrlVar
end tell
If you want to break it down a little further, you could
set SurfApp to "Internet Explorer"
set SiteAddy to "google"
set UrlVar to ("http://www." & SiteAddy & ".com") as string
tell application SurfApp
open location UrlVar
end tell
But I think the first one suits your needs. Post back give report
SC
By the way if you use IE and pull scripts off the bulletin board, try this script I wrote that “opens selected code text” in a post “directly into a script editor window”: