Is it possible to embed object in to excel file?
I tried using "$sheet.OLEObjects().Add()
but was not able to get the right parameters to embed the object. I'm wondering if its possible to do it using powershell.
Any help on this matter would be greatly appreciated.
Edit : 21/12/2020
Here is the code I was referring to :
$src = "C:\Temp\Temp\src.xlsm"
$dst="C:\Temp\Temp\dst.xlsx"
$excel=New-Object -ComObject Excel.Application
$excel.visible = $false
$excel.DisplayAlerts=$false
$book = $excel.workbooks.Open($src, $null, $false)
$sheet = $excel.worksheets.item("sheetname")
[void]$sheet.Activate()
$sheet.OLEObjects().Add($missing, $dst, $false, $true,$missing, 1, "Attachment', $missing, $missing, $missing)
[void] $book.save()
[void]$book.Close()
[void]$book.Quit()
The above code gives error "Unable to get the Add property of the OLEObjects class.
Also tried the below which actually attaches an empty sheet to the woorkbook but not the destination file and also gives the same error message as above.
$sheet.OLEObjects().Add('excel.sheet', $missing, $false, $true, $dst, 1, "Attachment', $missing, $missing,$missing)