Running Publisher macros from Powershell script

310 views Asked by At

I am trying to run a Publisher macro from Powershell, but I am getting an error when trying to run the macro. Here is the error:

Method invocation failed because [Microsoft.Office.Interop.Publisher.ApplicationClass] does not contain a method named 'Run'

I've seen code with the .run method on a publisher object in powershell around. So, has this method been removed? I can't seem to find it in the VBA documentation. https://learn.microsoft.com/en-us/office/vba/api/publisher.application

The method appears when I use an Excel COM object.

$publisher = New-Object -ComObject Publisher.Application
$document = $publisher.Open($labelPath)

$publisher.Run('macro', $arg1, $arg2) #method not found

$document.Close()
$publisher.Quit()
0

There are 0 answers