Powershell:使用参数调用Word Sub不起作用

时间:2017-09-01 06:30:46

标签: vba powershell

我想从Powershell ISE打电话给我2个vba潜艇;我可以成功调用wordsub,但调用wordsub1parameter不会触发msgbox并且日志中没有错误:

Sub wordsub()

MsgBox ("hello from sub")

End Sub

Sub wordsub1parameter(greetings)

MsgBox (greetings)

End Sub

Powershell脚本:

$file = "C:\test\test.docx"

$Word = New-Object -ComObject Word.Application
$Word.Visible = $True

$Document=$Word.documents.open($file)

$Word.run("wordsub")
$Word.run("wordsub1parameter", "hello")

这不可能吗?

0 个答案:

没有答案