vba - Macro runs perfectly in excel but error message when called in powershell -
i have written macro calls 3 other macros inside of in order use public variable in 3 macros . macro runs excel when try , call macro in power shell receive error message.
here macro works in excel:
public fnum integer sub master_macro() combine_workbooks automate_search delete_duplicate end sub
here powershell code:
#powershellscript test automation of 80% test # start excel $excel = new-object -comobject excel.application #open file $filepath = 'c:\file build project\!notes filebuild project\pf pm data collection workbook-template our macro' $workbook = $excel.workbooks.open($filepath) #no point see excel since else shutdown in vba $excel.visible = $false $excel.displayalerts = $false #run macro save workbook close excel $excel.run("master_macro") $workbook.save() $excel.quit()
finally here error message receive when powershell run:
exception calling "run" "31" argument(s): "cannot run macro 'delete_duplicates'. macro may not availabl e in workbook or macros may disabled." @ c:\file build project\testing\powershellscript_test_automation.ps1:17 char:11 + $excel.run <<<< ("delete_duplicates") + categoryinfo : notspecified: (:) [], methodinvocationexception + fullyqualifiederrorid : dotnetmethodexception
any appreciated
Comments
Post a Comment