ioripalm 1 Report post Posted September 27, 2017 $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
water 1,770 Report post Posted September 27, 2017 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 - WikiOutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example ScriptsExcel - Example Scripts - WikiWord - WikiPowerPoint (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
ioripalm 1 Report post Posted September 29, 2017 (edited) On 2017/9/28 at 3:25 AM, water said: 问题似乎不是由信任设置引起的,而是Excel在读取和验证文件的结构时遇到问题。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-美国和RS = EN-US&AD = US&ocmsassetID = HA010355931 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 September 29, 2017 by ioripalm Share this post Link to post Share on other sites
water 1,770 Report post Posted September 29, 2017 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 - WikiOutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example ScriptsExcel - Example Scripts - WikiWord - WikiPowerPoint (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
Juvigy 28 Report post Posted October 2, 2017 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