0

I simplified the problem for the purpose of this question:

I have a file Return13.xlsm with following macro content:

Function Return13() As Integer
   Return13 = 13
End Function

And following Powershell script:

$E = New-Object -ComObject Excel.Application
[Void]$E.Workbooks.Open("C:\MyMagicalFolder\Return13.xlsm")
$x = $E.Run("Return13")

In both Powershells I get following error:

Exception calling "Run" with "1" argument(s): "Exception from HRESULT: 0x800A03EC"

For the record - the functionality worked ~1month ago fine. Now - the only semi-constructive feedback on the matter I found on the "web" is that one of Windows Updates could brake it but I have no idea how to find it and what to do about it - given I work in enteprise environment and can't undo this patch (and I would have to do it on more than just my personal dev machine).

Any ideas?

For the record I have Windows 8.1 64bit with Office 365 32bit. Powershell Core used is 64bit and old Powershell 32bit.

braX
  • 11,506
  • 5
  • 20
  • 33
nimdil
  • 1,361
  • 10
  • 20
  • 1
    Check the file permissions and ensure you have read/write/execute. Also, make sure the worksheet is not protected. – Kirill Pashkov Nov 22 '18 at 12:22
  • Excel object model is enabled, all macros are allowed to run, file permissions are fine. The workbook is freshly crafted (new -> alt+f11 -> macro above -> save) so there's no protection on nothing. – nimdil Nov 22 '18 at 12:49
  • If that changes anything the wbscript gives the same error – nimdil Nov 22 '18 at 13:21
  • 1
    Try: $x = $E.Run('ThisWorkbook.Return13') cf https://stackoverflow.com/questions/19536241/calling-excel-macros-from-powershell-with-arguments – Tragamor Nov 22 '18 at 23:00
  • @Tragamor thanks for suggestion - however the module prefix is not needed most of the time and haven't helped here either. – nimdil Nov 23 '18 at 09:50

0 Answers0