Jump to content

Error Reading Esxcel Comment


Recommended Posts

I am experiencing a error when I try to read a cell comment when a comment does not exist.  I have reported this as bug but the moderators have said this is this is a consequence of the recent change in how COM errors are dealt with.  Offending code is below along with the message that appears in the console window.  I tried installing a COM error handler, but the code does not trigger the handler.  Is anybody else experiencing this issue and have you found a solution.  The code works perfectly if the cell has a comment.

$sStr = $oExcel.Cells($iRow, $iColumn).Comment.Text
$sStr = $oExcel.Cells($iRow, $iColumn).Comment^ ERROR

 

 

Link to comment
Share on other sites

Welcome to AutoIt and the forum!
My suggestion: Use the Excel UDF that comes with AutoIt. It does the COM error handling stuff for you. Remember that _Excel_RangeRead can only read the comment of a single cell (Excel limitation).

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I figured it out.  I adjusted my code to test to see if the Comment object exists before I try to read the text.  IsObj($oExcel.Cells($irRow, $iColumn).Comment) does the trick.  IsObj reports failure if a comment does not exist.

BTW, the Excel UDF does not include functions for Comments so it is not much help in that regard. 

Link to comment
Share on other sites

Ops, you are correct. That is still in the pipeline.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...