Benches macOS

5

Open Application in background during a script

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

I have a script which requests Excel to activate, run some commands and then quit once finished. Now, my question, can this be performed in the background where the user won't see the excel splash screen and feedback noises during saves etc? My feeling is this is difficult, if not impossible.

Your thoughts, please.

5 replies

Sign in or join Beachball Help to reply.

  1. 0

    red_menace

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Using Excel's scripting dictionary (instead of GUI scripting) should let you do things with it in the background, and telling Excel to launch (instead of activate) should start it running without the normal startup windows and dialogs. I say should for these, since that is how it is supposed to be, but it is up to the particular application.

  2. 0

    vem234

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Red Menace,

    Thank you for your valuable input. I will look hard into the suggested routes and will get back to this post in short order. I feel as though the attendees in this forum are somewhat more willing to help than say the other, advanced forums out there. A similar question was posted in one of those forums and several hundreds of views were observed with zero responses.

  3. 0

    Camelot

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    can this be performed in the background where the user won't see the excel splash screen and feedback noises during saves etc?

    Can't do much about the noise (other than turning off the sound volume, I suppose), but if you want to launch a program in the background, use the
    launch command:

    tell application "Microsoft Excel"

    launch -- launches the application in the background

    -- other commands go here

    end tell

    If you use the standard 'activate', or no command at all the target application will open frontmost. 'launch' takes care of that element.

  4. 0

    vem234

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Yes, implementation of the launch command will place Excel in the background. Now, with this in mind, would I be able to run a script that sends application commands to a specific Excel file (such as specific row modifications, save etc.) in the "background"? Maybe this is the chore for a shell script.

    In other words, on execution of a script, I would like the following to occur in the background: launch Excel, open a file, do row modifications, save it, and quit excel. This is the last piece of a very valuable application that I am building. Thanks all.

  5. 0

    Camelot

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    In other words, on execution of a script, I would like the following to occur in the background: launch Excel, open a file, do row modifications, save it, and quit excel. This is the last piece of a very valuable application that I am building. Thanks all.

    Sure. Any command can be targeted to any application, document, etc.

    I'm not overly familiar with Excel scripting, but the principle would be something like:

    tell application "Microsoft Excel"

    launch -- open the application

    open file "HD:path:to:some.xls

    tell document 1

    -- commands to execute in the frontmost document

    save -- save the document when you're done

    end tell

    close document 1 -- close it when you're done

    quit -- quit Excel

    end tell