I need to automate something in excel. The first step should be to run a macro that is started by clicking a VBA-Button. Is there a way I can click a VBA-Button using Powershell?
Thanks!
I need to automate something in excel. The first step should be to run a macro that is started by clicking a VBA-Button. Is there a way I can click a VBA-Button using Powershell?
Thanks!
Provide macro name hidden inside this button, as an argument of cmd command.
Steps for you:
Try running with Powershell:
"path_to_excel_app" "path_to_excel_file_with_macro" /x macro_name
Here is my working exaple with MS access:
"C:\Program Files (x86)\Microsoft Office\Office15\MSACCESS.EXE" "R:\path_to_macro_file\AccessFileWithMacro.accdb" /x macroName
You only need to run this 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