Microsoft 365 and Office | Excel | For education | Windows
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
how do you open and run a .bat file from inside excel
To execute a .bat file from inside Excel, you can use VBA (Visual Basic for Applications). Here’s a simple way to do it:
ALT + F11 to open the VBA editor.Insert, and then Module. Sub RunBatchFile()
Dim batFilePath As String
batFilePath = "C:\path\to\your\file.bat" ' Change this to your .bat file path
Shell batFilePath, vbNormalFocus
End Sub
batFilePath to the location of your .bat file.F5 or by going back to Excel, selecting Macros from the Developer tab, and running RunBatchFile.This will execute the specified .bat file when the macro is run.