Calling macro in a batch script - excel

Can I run a macro in a batch script?
like
SET HOME_PATH=%loaction%
vba %macro%
Is it possible to call a macro in batch script?

You can open an excel file from a batch script and run a macro whenever the excel file is opened, but whatever you are trying to do will probably be done better if it is not done with a macro

Related

Python 2.7 - opening excel with embedded macro

I wrote a simple script in Python-2.7 to open an excel file with an embedded macro in it (macro starts at excel opening) using os.startfile(excel_file_name). Problem is my Python script pauses until excel calculation is finished, while it is needed to keep on running, so this script can check for how long excel is open. Any idea how to approach this?
Regards

How to apply macro from file1 to file2?

I have .csv files with different filenames put on a shared drive twice a day.
I need to apply a macro I wrote, (with much help) to the most recently created file with no user input so I can add it to Windows Task Scheduler.
For the task scheduler part I was going to use a PowerShell script.
How do I have Excel open a macro from file1 and run it on file2, where the filename on file2 changes daily?
I would recommend to store your macro in Personal Macro Workbook. With that you can run it on every excel file you open.
Here is how you do it:
https://support.office.com/en-us/article/create-and-save-all-your-macros-in-a-single-workbook-66c97ab3-11c2-44db-b021-ae005a9bc790

How to write the excel file by Perl with VBA macro inside

My Perl scripts will write the excel file as the output to the user, and I also need this excel file includes the VBA codes.
That means after the use open the excel file, they can run the VBA macro by click the button.
Can I use Perl to write the excel file with macro inside?
If it is unable to do so, the workaround may be :
1. the Perl only write the excel file without macro.
2. attach the macro to that excel file before send to user

How to copy an active excel sheet and save it into a new workbook using a vbs script?

I'm trying to copy an excel sheet that includes formulas and paste it into a new excel workbook as values and retaining the format using vbs script.
I'm currently doing it but instead of copying I'm saving it as a CSV.
So it is only saving the first page but it looses the format.
Please help.
Thank you.
I found a way around to fix this, I run a vbs to refresh and save the file. then with a batch file i run another script and open the file to only run a macro inside of it and the macro does the job.

Excel 2010 VBA - Continually Looking In Folder for File to Process?

I have a need to build a macro in Excel 2010 that basically runs continually (started by button or stopped by button) that looks into a file folder. If a file is created there and named a certain way then the macro opens it and processes the data inside. The file is then closed and deleted. The macro then continues on to watch the file folder for more files to process
Is this a reasonable / doable macro that I could create in Excel with VBA? Can VBA continually run without issues?
Best Regards
Andy
Is your program continuously pulling changing data from the Excel sheet? If not, I would advise creating the program in another language and running in a continuous loop containing your code and the sleep() function. If so, then I would recommend using the worksheet change event, and you cannot edit the worksheet while a macro is running(even if you use the sleep/wait command in VBA)
This link might also prove helpful: How to get VBA Macro to run continuously in the background?
see this thread for some ideas:
https://superuser.com/questions/226828/how-to-monitor-a-folder-and-trigger-a-command-line-action-when-a-file-is-created
the first answer probably will do it, just trigger the excel macro you want from that. You can get as fancy as you want with the execution. The application.ontime function only works if excel is open, I believe.
What you want is to find a way to monitor the folder constantly.

Resources