ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run Excel Macro in a Batch File (https://www.excelbanter.com/excel-programming/309299-run-excel-macro-batch-file.html)

DP[_3_]

Run Excel Macro in a Batch File
 
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



papou[_10_]

Run Excel Macro in a Batch File
 
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


"DP" a écrit dans le message de
rs.com...
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





DP[_3_]

Loop through all the lines in a sheet (Was: Run Excel Macro in a Batch File)
 
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



"papou" wrote in message
...
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


"DP" a écrit dans le message de
rs.com...
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








All times are GMT +1. The time now is 06:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com