View Single Post
  #7   Report Post  
Old March 26th 19, 11:58 PM posted to microsoft.public.excel.programming
Adrian Caspersz Adrian Caspersz is offline
external usenet poster
 
First recorded activity by ExcelBanter: Sep 2016
Posts: 11
Default executing VBA macro in Excel from OLE

On 26/03/2019 22:39, Lynn McGuire wrote:
On 3/26/2019 3:01 PM, Adrian Caspersz wrote:

Cool, I got it to work with the following and my macro was run:

PS C:\Users\lmc $E = New-Object -ComObject Excel.Application
PS C:\Users\lmc $workbook = $E.Workbooks.Open("C:\dii\spreadsheet2.xlsm")
PS C:\Users\lmc $E.Run("testmacro")
PS C:\Users\lmc $workbook.save()
PS C:\Users\lmc $workbook.close()

But I could not get Excel to quit:

PS C:\Users\lmc $workbook.quit()


$E.quit() should work.

--
Adrian C