Jump to content
anubis

Error Reading Esxcel Comment

Recommended Posts

anubis

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

 

 

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
anubis

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. 

Share this post


Link to post
Share on other sites
water

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
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

×