anubis

Error Reading Esxcel Comment

4 posts in this topic

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



#2 ·  Posted (edited)

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


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

Share this post


Link to post
Share on other sites

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

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