# How to add comments/notes to excel file cell

**URL:** <https://forums.powershell.org/t/how-to-add-comments-notes-to-excel-file-cell/14042>\
**Category:** PowerShell Help\
**Created:** [March 27, 2020, 7:13am UTC](https://forums.powershell.org/t/how-to-add-comments-notes-to-excel-file-cell/14042 "2020-03-27T07:13:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonauskas](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jonauskas](https://forums.powershell.org/u/jonauskas)\
**Post date:** [March 27, 2020, 7:13am UTC](https://forums.powershell.org/t/how-to-add-comments-notes-to-excel-file-cell/14042/1 "2020-03-27T07:13:53Z")

</div>

Hello everyone,

I am trying to add comments/notes to excel file cell, right now i am using ImportExcel module. I am encountered with these problems:

1. I am using AddComments method which should add note with text and author, but it only adds the note text.
2. When i try to overwrite comment I can't, since I get excel file error 

&nbsp;

Script that I am using:

Install-Module Install-Module -Name ImportExcel -RequiredVersion 7.0.1  
$FileName = “FileName.xlsx”  
$ExcelFile = Open-ExcelPackage -Path PathToTheFile$FileName  
$WorkSheet = $ExcelFile.Workbook.Worksheets[“SheetName”]  
$WorkSheet.Cells[“A4”].AddComment(“Hello world”, “Jonas”)  
Close-ExcelPackage $ExcelFile -Show

---

<div class="post-metadata">

**Author:** ![firmbyte](https://avatars.discourse-cdn.com/v4/letter/f/e68b1a/32.png) [@firmbyte](https://forums.powershell.org/u/firmbyte)\
**Post date:** [March 28, 2020, 7:41am UTC](https://forums.powershell.org/t/how-to-add-comments-notes-to-excel-file-cell/14042/2 "2020-03-28T07:41:22Z")

</div>

I wasn’t able to figure out how to do this using the importexcel module. But using the com object Excel.Application, i was able to do it like this

```
$file = "C:\temp\ssis.xlsx"
$Sheet = 'sheet4'
$Range = 'A11'
$Item = '1,11'
$xl = New-Object -com Excel.Application
$xl.visible = $true
$xl.DisplayAlerts = $False
$wb = $xl.Workbooks.Open($file )
$ws = $wb.worksheets | ?{$_.name -eq $Sheet}
$ws.Cells.Item($Item) = 'A value in cell $Range.'
[void]$ws.Range($Range).AddComment()
$ws.Range($Range).comment.Visible = $False
[void]$ws.Range($Range).Comment.text("IB: `r this is a comment")
$Ws.saveAs($file)
$ws.close
$xl.Quit()
```

&nbsp;

---

<div class="post-metadata">

**Author:** ![firmbyte](https://avatars.discourse-cdn.com/v4/letter/f/e68b1a/32.png) [@firmbyte](https://forums.powershell.org/u/firmbyte)\
**Post date:** [March 28, 2020, 7:45am UTC](https://forums.powershell.org/t/how-to-add-comments-notes-to-excel-file-cell/14042/3 "2020-03-28T07:45:00Z")

</div>

I couldn’t find how to do this using the importexcel module but with the excel com object, I was able to do it like this:

```
$file = "C:\temp\ssis.xlsx"
$Sheet = 'sheet4'
$Range = 'A11'
$Item = '1,11'
$xl = New-Object -com Excel.Application
$xl.visible = $true
$xl.DisplayAlerts = $False
$wb = $xl.Workbooks.Open($file )
$ws = $wb.worksheets | ?{$_.name -eq $Sheet}
$ws.Cells.Item($Item) = 'A value in cell $Range.'
[void]$ws.Range($Range).AddComment()
$ws.Range($Range).comment.Visible = $False
[void]$ws.Range($Range).Comment.text("IB: `r this is a comment")
$Ws.saveAs($file)
$ws.close
$xl.Quit()
```

---

<div class="post-metadata">

**Author:** ![jonauskas](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jonauskas](https://forums.powershell.org/u/jonauskas)\
**Post date:** [March 28, 2020, 1:59pm UTC](https://forums.powershell.org/t/how-to-add-comments-notes-to-excel-file-cell/14042/4 "2020-03-28T13:59:43Z")

</div>

Hey, yeah it looks like importexcel module does not have capability to do it. Thanks for the solution 🙂

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:30pm UTC](https://forums.powershell.org/t/how-to-add-comments-notes-to-excel-file-cell/14042/5 "2024-05-16T20:30:02Z")

</div>

Closed on May 16, 2024, 8:30pm UTC


