📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

Problem launching Excel from command line

Options
rmg1
rmg1 Posts: 3,159 Forumite
Part of the Furniture 1,000 Posts Name Dropper
Hi all

I need to be able to schedule a task to launch Microsoft Excel using a batch file which is attached to a scheduled task.
I also need it to enable macros as our system policy won't allow macros security to be set on "low" (and i's not recommended anyway).
Enabling macros will allow the spreadsheet to update links, publish and exit on its own (I've got that bit working), I just need the batch file command to automate the whole think from start to finish.
I can't leave the Excel file open all the time and use the "Application.Ontime" command as the server closes all the files down overnight to prevent problems.
Anyone any ideas?
:wall: Flagellation, necrophilia and bestiality - Am I flogging a dead horse? :wall:

Any posts are my opinion and only that. Please read at your own risk.

Comments

  • espresso
    espresso Posts: 16,448 Forumite
    Part of the Furniture 10,000 Posts Combo Breaker
    Experiment with the following batch file lines:

    to open excel

    start /d "C:\Program Files\Microsoft Office\Office" EXCEL.EXE

    or to open an excel file

    start /d C:\finance\spreadsheets budget.xls


    :doh: Blue text on this forum usually signifies hyperlinks, so click on them!..:wall:
  • geewhiz
    geewhiz Posts: 1,129 Forumite
    Part of the Furniture 1,000 Posts Combo Breaker
    You can't enable macros automatically as that would mean any virus could do the same.

    Have a look at this document, you might get round this by digitally signing it especially if it's only running on the one machine.
  • Dime_Bar
    Dime_Bar Posts: 584 Forumite
    Part of the Furniture 500 Posts Name Dropper Combo Breaker
    The comman you need to run in the batch file to open Excel with the workbook is

    excel.exe "c:\pathtothefile\workbookname.xlsm"

    This will open the file but as you will see the file will still have macros disallowed. I don't belive there is a command line switch to change this, however the defualt setting of Disable all macros with notification will not apply to digitally signed projects that are from trusted publishers.

    To get your self a digital certificate here are the instructions

    Once you have done this sign your VBA project by going to the Visual Bassic window and Tools>Digital Signiture and selecting the one you have just set up.

    You then need to go to excel and open the file you will get the usual warning but with the option to add the publisher to the trusted publishers. Select this and you should be able to open the file from the above command line with the macros automatically enabled.

    Hope that makes sense
    The only way of finding the limits of the possible is by going beyond them into the impossible.
    Arthur C. Clarke
  • rmg1
    rmg1 Posts: 3,159 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    Thanks guys.
    Should have remembered about digital signatures as I've used them before (doh!)
    :o
    :wall: Flagellation, necrophilia and bestiality - Am I flogging a dead horse? :wall:

    Any posts are my opinion and only that. Please read at your own risk.
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 351.1K Banking & Borrowing
  • 253.1K Reduce Debt & Boost Income
  • 453.6K Spending & Discounts
  • 244.1K Work, Benefits & Business
  • 599K Mortgages, Homes & Bills
  • 177K Life & Family
  • 257.4K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16.1K Discuss & Feedback
  • 37.6K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.