Jump to content

Excel Read Only Issue - Activate


RamadSula
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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 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 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 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

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.

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...