Passing a variant through COM object via PowerShell to run a macro in PowerPoint

前端 未结 2 1152
萌比男神i
萌比男神i 2021-01-05 01:34

Trying to string the title together was enough of a challenge...

I am trying to run some PowerPoint macros from PowerShell. I have gotten quite good at running macro

2条回答
  •  被撕碎了的回忆
    2021-01-05 01:43

    Maybe try removing the [ref] in the line of code below or try changing it to [val]

    $PowerPoint.run("macros.pptm!IAM",[ref]"Feb")
    

    So either:

    $PowerPoint.run("macros.pptm!IAM","Feb")
    

    or:

    $PowerPoint.run("macros.pptm!IAM",[val]"Feb")
    

    And then also make sure that the PowerPoint macro is expecting the variable to be passed ByVal. For example something like this:

    Sub IAM(ByVal sMonthName As String)
    

提交回复
热议问题