sg2012 wrote:Hey I am So Sorry.
I framed wrong Question.
Yeah I knew ExecuteCommand().
But how to call Macro from bat file?
I have found something like this:
C:\temp\test.txt /m="C:\temp\macro.mac"
But its not workin..
Gee, I wonder why. Perhaps had you quoted the
entire command line of
Code: Select all
uedit32 c:\temp\test.txt /m="c:\temp\macro.mac"
which you presumably found on
this link (and which you quoted without taking the time to read through the entire context of the page), you would have understood that that was unlikely to work unless you bought the Ultra Edit application from the company concerned. Those are not native batch commands, they're commands for Ultra Edit.
Since this is a really, really bad idea (as you've been told repeatedly by many people), and since I'm not in the business of propagating really, really bad ideas, I'm not going to spell out the solution.
But while I won't give you an actual
road map to Hell, I will, however, give you a compass and point you in the right direction. It's then up to you whether you want to walk that path and if you do, well, Pilate isn't the only Roman who washes his hands of the consequences.
Consider:
- A Batch file can be used to launch the Excel executable (excel.exe) by simply specifying the full path to it.
- When you use a command line to launch Excel, you can open a file along with it by either putting the file in the xlStart folder (look it up in Excel Help; the relevant topic is "Customize how Excel starts"), or by including the path to the file in the command line.
- Alternatively if the .xls extension is correctly associated with Excel, all you would need to do is execute a command line pointing to an .xls file. That would automatically open Excel and load the file into it.
- You can have a macro run automatically upon load by creating it in the Workbook's Workbook_Open event. (Again, all explained in Excel's Help.)
Now, before you do this and get disappointed, you may want to consider the one thing that Martin didn't mention... where exactly do you think that the batch file will run? Consequently, where do you think that the Excel session will open?
Martin is correct if you want some kind of macro to run on the server alone. But if you're expecting this to be some sort of solution which will allow the server to communicate back to the
users (which you may or may not, I have no idea what it is that you're trying to do).. this is not it.