Run Excel Macro in a Batch File

  • Thread starter Thread starter DP
  • Start date Start date
D

DP

Hello,

I need to do the following in a batch process, in a DOS batch file (under
Win2000):

1. Look into the certain folder, there is always one Excel file (with
arbitrary names).
2. Open that file with Excel.
3. Run a certain macro, say Macro1, on that file.
4. Close Excel

How should I properly approach that?

Thanks in advance,
DP
 
Hello
Would a VB script suit you?
If it does, open a new text document and paste and amend accordingly the
following example:
Dim objXL
Set objXL = WScript.CreateObject("Excel.Application")
objXL.Visible = TRUE
objXL.WorkBooks.Open("C:\Test\YourWorkbk.xls")
objXL.run("Macro1")
'Do some other stuff
Set objXL = Nothing

Save the file with the .VBS extension and double-click to run

HTH
Cordially
Pascal
 
Hello,

Thank you very much! I will try that.
And now, if you pardon my ignorance, let me ask you that silly question:

How I can iterate in a macro through all the lines of an Excel file?
Strangely, I couldn't find help on that in Excel help. Where that and
similar question about the essential macro commands could be answered?

Thank you,
DP
 
Back
Top