![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Posts: 2
|
Hi people,
Is there a way of running excel macro from command line or using .bat ( batch file or operating system script file ). I want to write a batch file which converts text file into excel file with certain columns protected and store it in new file name. Can it be done from dos/windows/unix command prompt without invoking MS-Excel by double clicking? Thanks in advance, -N |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Reply, I don't believe this is possible. It is possible to run a commandline instruction or a batch file from Excel if that's any help to you.
|
|
|
|
|
|
#3 |
|
New Member
Join Date: Mar 2002
Posts: 2
|
I need excel macro to be executed from command line. ( not command line from excel ). Will this work?! i)save a text file with .xls extension ii) write a macro, put it as part of file which should run automatically when user opens the file. ideas welcome.. thanks and appreciate your suggestions |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Running the Excel sheet from the command line and starting the macros from the "Worksheet_Open" event would work, but with one snag.
You will be prompted to enable or disable macros when the workbook opens. There are two known ways to bypass this. 1. Lower the security of Excel on the Tools|Macros|Security menu. (This is not recommended by anyone as your susceptible to malicious macros) 2. Become a "trusted source" for the users using Digital Signatures. I haven't used these and you'll need to check XL help or microsoft.com for how to use this. (people on this board are wary of digital signatures as well) HTH |
|
|
|
|
|
#5 |
|
New Member
Join Date: Aug 2002
Posts: 44
|
I've been wondering about this too. My sheet has to be able to be opened without running the macro, too, though.
One trick might be to have the batch file create a dummy file on c: root, then have the Excel function check if that file exists. If it does, then it is meant to auto execute that particular function (or perhaps one of many depending on the name of the file). Then the batch file deletes the file after excel.exe exits. Whether the function modifies the spreadsheet requiring a save, and how to automate the save I don't know (yet). Any more clever ideas on how to do this? |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|