Does anyone know how to get VB to trigger an AppleScript?
VB being run from where?
Jon
Microsoft Office v.X
OK, even more info is needed. That’s not technically VB, it’s VBA (Visual Basic for Applications–there is a difference) and there are different flavors for each application (Word, Excel, etc.). What kind of script do you need to be run? Is this something that is going to be distributed or can you control the environment entirely? If so, your best bet is probably to use a similar method I’ve mentioned to get PHP & AppleScript to play together by having a folder action script or a stay open app watch a folder and have the VBA app write a file to the watch folder with the parameters you want to pass to the AppleScript. Have the VBA app wait until a file written by the AppleScript appears with the data returned by the AppleScript before continuing. In this way you can easily communicate between any app/language that allows you to read/write a file and AppleScript without needing any direct communication between the two.
All of this said, there may actually be direct hooks between VBA for (application x) and AppleScript so you wouldn’t have to do this tango in the first place.
Hope this helps.
Jon
Looking in the Word VBA help file, there is a Macscript command that allows you to run AppleScript code directly:
ThePath$ = Macscript("Choose File")
You just add your AppleScript code as plan text and the result will be passed to the VBA variable for use in the rest of your VBA code. Multi-line AppleScripts can be included by embedding carriage returns:
ThePath$ = Macscript("set the_file to Choose File" + (Chr(13)) + "return the_file as string")
Jon