ioripalm Posted September 27, 2017 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
water Posted September 27, 2017 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 2024-07-28 - Version 1.6.3.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 (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
ioripalm Posted September 29, 2017 Author 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
water Posted September 29, 2017 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 2024-07-28 - Version 1.6.3.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 (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
Juvigy Posted October 2, 2017 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now