My searches only led to something similar in VBA, but I have a different approach and in PowerShell for this problem.
I am new to PowerShell and I want to read all comments in Excel files and save them to a CSV file. Everything works except for reading the comment. The comment is a com object. How do I get the actual comment from the com object? Here is a snippet of the relevant code. I'm not able to do it with invokemember but perhaps I am doing it wrong. Thanks in advance.
ForEach ($File in (Get-ChildItem $folder -Include *.xls, *.xlsx, *.xlsm -Recurse))
{
$sh=$document.Sheets.Item($i)
$comments = $sh.comments
foreach ($comment in $comments)
{
#[System.__ComObject] <--- Must get this value | Add-Content -file.csv
}
}
I am also open to other methods to accomplish this.