我需要在Excel中自动执行某些操作。第一步应该是运行通过单击VBA-Button启动的宏。有没有办法可以使用Powershell单击VBA-Button?
谢谢!
答案 0 :(得分:0)
提供隐藏在此按钮内的宏名称,作为cmd命令的参数。
您的步骤:
尝试使用Powershell运行:
"path_to_excel_app" "path_to_excel_file_with_macro" /x macro_name
以下是我使用MS访问的工作:
"C:\Program Files (x86)\Microsoft Office\Office15\MSACCESS.EXE" "R:\path_to_macro_file\AccessFileWithMacro.accdb" /x macroName
答案 1 :(得分:0)
您只需要运行此PS
# 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