我想通过PowerShell脚本运行宏。我想出了如何启动宏。
$ExcelPath = "R:\01.DS\04.X-DS\13. Proposed plan\Proposed_plan_WINGS.xlsm"
$Excel = New-Object -ComObject Excel.Application
$Excel.Visible = $true
$Workbook = $Excel.Workbooks.Open($ExcelPath)
$Worksheets = $Workbooks.Worksheets
$Worksheet = $Workbook.Worksheets.Item(1)
$Excel.Run('Iris_prop_plan')
但是,当宏启动时,会出现一个弹出窗口,其中显示:更新值。 如何在代码中包含它?
答案 0 :(得分:0)
# start Excel
$excel = New-Object -comobject Excel.Application
#open file
$FilePath = 'FilePath'
$workbook = $excel.Workbooks.Open($FilePath)
##If you will like to check what is happend
$excel.Visible = $true
## Here you can "click" the button
$app = $excel.Application
$app.Run("MacroName")
##The macro name is the trigger of your button