We'd like to remind Forumites to please avoid political debate on the Forum... Read More »
📨 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
Posts: 3,159 Forumite


in Techie Stuff
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?
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.
Any posts are my opinion and only that. Please read at your own risk.
0
Comments
-
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:0 -
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 senseThe only way of finding the limits of the possible is by going beyond them into the impossible.
Arthur C. Clarke0 -
Thanks guys.
Should have remembered about digital signatures as I've used them before (doh!):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.0
This discussion has been closed.
Confirm your email address to Create Threads and Reply

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