Jump to content
Sign in to follow this  
RamadSula

Excel Read Only Issue - Activate

Recommended Posts

RamadSula

I apologize for the double forum posting , but this request morphed beyond the intent other forum.

Project:

I am creating GUI that runs a Document Marquee that cycles various Documents , i.e Word, PDF, Excel on a large display.

There is one Excel document that is a maintenance log that is READ Only

Request:

I have an issue in which I can open a read only Excel document but not give it focus with Sheet Activate

I apologize for the indirect addressing , I created an editable array for management to change documents in the Marquee.

Code snipet :

$logtxt = $Title[$Row][$Col] & " Attempt Active"

Call("WritetoLog", $logtxt)

$oExcel = ObjCreate("Excel.Application") ; Create initial Excel Object

$oExcel.WorkBooks($Title[$Row][$Col]).Sheets($Tab[$Row][$Col]).Select()

I still get Invalid Index Errors on Read Only when attempting to Select a read only worksheet.

09/27/2012 13:57:49 WorkBook maintenance crossover.xlsx [Read-Only] Tab maint log Attempt

09/27/2012 13:57:49 COM Error Hex Number is: 80020009

09/27/2012 13:57:49 COM Error Description is: Invalid index.

If I create another version of the excel document that is not Read-only, the error goes away.

Any thoughts on what may be causing it?

Share this post


Link to post
Share on other sites
water

Can you post a small reproducer here that showes the described behaviour? I mean an Excel workbook plus an AutoIt script to open the workbook and activate a sheet.

I would like to have a look at the problem. Maybe the Excel UDF needs to be modified as you assume.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - 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
water

I just ran this little reproducer script with a workbook with 3 worksheets and didn't have a problem:

#include <Excel.au3>

Global $oExcel = _ExcelBookOpen(@ScriptDir & "\Test.xlsx", 1, True) ; Open Read Only
$oExcel.WorkBooks(1).Sheets(3).Select()
MsgBox(0, "", "@error: " & @error & ", @extended: " & @extended)
_ExcelBookClose($oExcel, 0, 0)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - 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
RamadSula

Water

Thanks for the all help. I figured what is causing one error and figured out a workaround for the rest.

I began to create a simple hard coded version like you suggested that exploited the perceived weakness and discovered the error.

The problem was that I was using the exact Windows Title including the " [READ ONLY] " in its name.

I filtered out everything but the Name.Extension and the error message went away.

However I was still unable to switch back to this document once another document was opened, such as a PDF.

I experimented with assigning a separate Excel Object for each Excel document and found that I now could switch between

documents.

My document marquee is small , no more than nine documents, so having extra COM Objects is not huge deal.

Thanks again for all your help.

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
Sign in to follow this  

×