1

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()
BigBen
  • 46,229
  • 7
  • 24
  • 40
  • This is an interesting question - it looks like only certain Office applications have a `Run` method - e.g. Excel, Word, Access, Powerpoint, and Project - but others don't, such as Outlook and Publisher. I'm not sure what the workaround is or if any exists. – BigBen Apr 03 '19 at 21:43
  • It may have only been in previous versions of vba, but I can't find any documentation on it for earlier versions. It's interesting because there are other responses on here indicating that the method existed for Publisher in the past. – coderkid420 Apr 03 '19 at 21:54
  • Hmmm out of curiosity, can you share any of those responses? didn't find anything. – BigBen Apr 03 '19 at 21:57
  • It seems what I was looking at was Excel examples actually. I guess the method has never existed. It's a shame really, cause publisher does support macros. – coderkid420 Apr 03 '19 at 22:12

0 Answers0