ioripalm

How to reading a Excel in Protected View?

5 posts in this topic

 

 

1706081041da47c9620142f3c3.png

$lastSummaryXls = ObjGet(@ScriptDir & "\" & 07Summary.xls)
        If @error Then MsgBox(16, 1, "Error")
        With $lastSummaryXls.Worksheets("Summary")
                $EmpList = .cells(1, 1).resize(.UsedRange.Rows.Count , .UsedRange.Columns.Count).value
                $EmpList = $lastSummaryXls.parent.application.transpose($EmpList) 
                ;_ArrayDisplay($EmpList)
                .parent.close(False)
        EndWith

The above code has been tested if the open excel file is protected, such as the file is downloaded from the network, or U disk, or above the office version of Office opened 97 office xls file, excel default security options will prompt the excel file Is protected, and can not be modified by default (unless all protection is turned off in the office's options - trust settings).
If you are using excel to manually open this file, you can click excel above the protected view - edit anyway to lift the protection (only need to set once, office will remember that this file is trusted). Again use Au3 can read excel to get the data.

Please help me to see how read-only way to open the protection of the excel file.Thank  you!!!

07Summary.xls

Share this post


Link to post
Share on other sites



The problem does not seem to be caused by the trust settings but by Excel having a problem reading and validating the structure of the file.
https://support.office.com/en-us/article/What-is-Protected-View-d6f09ac7-e6b9-4495-8e43-2bbcdbcb6653?CTT=1&CorrelationId=dbc4e198-ee91-49ae-992a-e342938cd2e6&ui=en-US&rs=en-US&ad=US&ocmsassetID=HA010355931

 


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

#3 ·  Posted (edited)

On 2017/9/28 at 3:25 AM, water said:

Hi

How to use au3 to remove file protection?

Does the test use the read-only parameter to open the file failed, can the other way to try to read the data?

Thank you!

Edited by ioripalm

Share this post


Link to post
Share on other sites

The site I pointed you to, describes that there seems to be a problem witht he structure of your Excel file. So you can't expect valid results by just removing the proteced view.


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

#5 ·  Posted

I think it would depend on the real reason the file opens in protected mode. Sometimes this is resolved by saving the file as xlsx.

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