Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 如何从Excel运行.bat文件?_Batch File_Xls - Fatal编程技术网

Batch file 如何从Excel运行.bat文件?

Batch file 如何从Excel运行.bat文件?,batch-file,xls,Batch File,Xls,我在不同的位置有5个批处理文件,我想通过Excel运行它们,如下所示: F:\Financial\Data\Reports\ExpensesYTD Batch1.bat, Batch2.bat, Batch4.bat F:\Financial\Data\Reports\AccountPnlMTD Batch5.bat, Batch6.bat, Batch7.bat 我想通过宏使用excel运行批处理文件。excel宏应该调用它们所在的.bat批处理文件并运行。请帮助我执行此操作。您可以通过

我在不同的位置有5个批处理文件,我想通过Excel运行它们,如下所示:

F:\Financial\Data\Reports\ExpensesYTD 
Batch1.bat, Batch2.bat, Batch4.bat

F:\Financial\Data\Reports\AccountPnlMTD
Batch5.bat, Batch6.bat, Batch7.bat

我想通过宏使用excel运行批处理文件。excel宏应该调用它们所在的.bat批处理文件并运行。请帮助我执行此操作。

您可以通过宏VBA脚本运行批处理文件。例如:

Sub RunBatch()
    Call Shell(Environ$("COMSPEC") & " F:\Financial\Data\Reports\ExpensesYTD\Batch1.bat", vbNormalFocus)
End Sub
可以使用工作表更改事件创建下拉框。像下面这样

将范围更改为显示下拉框结果的单元格,并更改宏名称。此外,此代码将放在工作表的代码中,而不是新模块中

Sub Worksheet_Change(ByVal Target As Range) 
    Select Case Target.Range("A1").Value 
    Case "First macro Name" 
        Call First_Marco 
    Case "Second macro Name" 
        Call Second_Marco 
    Case "Third macro Name" 
        Call Third_Marco 
    Case "Fourth macro Name" 
        Call Fourth_Marco 
    End Select 
End Sub

Thx..Dtmland。我想一个接一个地经营。(在一个下拉框中,我可以在其中运行salet.bat文件)。