donnyh13 Posted July 29, 2024 Posted July 29, 2024 (edited) Greetings AutoIt community! I did a quick search and found nothing posted for working with WPS Office using AutoIt so far, though I did see a few requests for it over the years. In my testing and research I have found that WPS Office seems to be just a free, re-branded version of MSOffice. Underneath the makeup, the COM methods etc are all the same, even the CLSID’s! That being the case you can use the UDF’s by water (or others) meant for working with Microsoft Office’s products, such as the Word and Excel UDF’s included with AutoIt already, as well as the PowerPoint UDF by water, found here: https://www.autoitscript.com/forum/files/file/374-powerpoint-udf/ That being said, I have not exhaustively tested automating WPS using the MSWord COM methods. Though I have used many MSOffice COM methods, etc., for automating WPS without a problem, you are encouraged to do testing yourself and make sure it works. I do not have much experience with MSOffice and related products, and thus may not be able to help much with bugs, but I will try to help as time permits. The question will arise, why did I have to make a function, since these two Office programs are seemingly identical? Well, First, to open a new instance of WPS Office programs (Writer, Spreadsheets, Presentation), the Class names are different. (KWPS.Application vs Word.Application; KWPP.Application vs PowerPoint.Application; KET.Application vs Excel.Application). And secondly, when connecting (or attaching) to an existing instance of WPS, you can easily get a MSOffice application Object instead of a WPS Application Object, and vice versa, if you so happen to have both installed and running. Thus I added a check for the Registry path to contain the string “\kingsoft\” to ensure you retrieve the intended object. (If anyone has a better method, I would appreciate any hints. The CLSID’s are identical, as well as the class name when it is running (Word.Application; Excel.Application; PowerPoint.Application)) So far I haven’t come up with a better name, so I have called it simply “WPS Office Adapter” because it allows you to use MS Office UDF functions for WPS. Any suggestions for a name will also be appreciated. The functions I made are copies from those written by water in the respective MS Office UDFs, with modifications to work with WPS, and some personal preference. Once you retrieve the Object you need for the WPS application, simply use those Objects in the respective MS Office UDF function. Also, in order for the examples of WPS Presentation to work, you will need to modify the Include path to point to the PowerPoint UDF, or place a copy into the main WPS UDF folder. Question or comments, or suggestions are welcome and appreciated. And also, if you wish to take this function and improve it or expand it, feel free, I’m not intending to go further than I have, with the exception of perhaps bug fixes as time permits. The Functions that replace existing MS Office functions are as follows: _WPS_Presentation_Attach -- Replaces --> _PPT_PresentationAttach _WPS_Presentation_Open -- Replaces --> _PPT_Open _WPS_Spreadsheets_BookAttach -- Replaces --> _Excel_BookAttach _WPS_Spreadsheets_BookList -- Replaces --> _Excel_BookList _WPS_Spreadsheets_Open -- Replaces --> _Excel_Open _WPS_Writer_Create -- Replaces --> _Word_Create Previous versions can be found here: https://github.com/donnyh13/WPS-Office-Adapter Best regards, WPS-Office-Adapter-0.1.0.zip Edited Monday at 04:42 PM by donnyh13 mLipok 1 LibreOffice UDF Scite4AutoIt Spell-Checker Using LibreOffice WPS Office adapter — Use MS Word UDFs with WPS Office! LibreOffice API Inspector tools Spoiler "Life is chiefly made up, not of great sacrifices and wonderful achievements, but of little things. It is oftenest through the little things which seem so unworthy of notice that great good or evil is brought into our lives. It is through our failure to endure the tests that come to us in little things, that the habits are molded, the character misshaped; and when the greater tests come, they find us unready. Only by acting upon principle in the tests of daily life can we acquire power to stand firm and faithful in the most dangerous and most difficult positions."
Solution donnyh13 Posted Monday at 04:41 PM Author Solution Posted Monday at 04:41 PM (edited) New minor release. v0.1.0 Fixed a missing Return which was causing a new WPS instance to be created each call, regardless if one was already open. Integrated Excel close on quit so that Excel_Close will work as normal. Sorry it took so long to find and fix, new file is in first post. Best regards, Donny Edited Monday at 04:41 PM by donnyh13 argumentum 1 LibreOffice UDF Scite4AutoIt Spell-Checker Using LibreOffice WPS Office adapter — Use MS Word UDFs with WPS Office! LibreOffice API Inspector tools Spoiler "Life is chiefly made up, not of great sacrifices and wonderful achievements, but of little things. It is oftenest through the little things which seem so unworthy of notice that great good or evil is brought into our lives. It is through our failure to endure the tests that come to us in little things, that the habits are molded, the character misshaped; and when the greater tests come, they find us unready. Only by acting upon principle in the tests of daily life can we acquire power to stand firm and faithful in the most dangerous and most difficult positions."
water Posted 18 hours ago Posted 18 hours ago Added your UDF to the Wiki donnyh13, argumentum and mLipok 1 2 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
water Posted 17 hours ago Posted 17 hours ago I just downloaded your WPS UDF and compared it with the Excel UDF, function _Excel_Open. Winmerge only displayed a few lines as changed. A crazy idea popped up Add a WPS compatibility mode to the MS Office UDFs. A script would only need to set a global variable ($g__WPS_Compatibility = True) All functions would then handle WPS like MS Office without further changes. What's your opinion? donnyh13 1 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
donnyh13 Posted 13 hours ago Author Posted 13 hours ago (edited) 4 hours ago, water said: Added your UDF to the Wiki Thank you 4 hours ago, water said: What's your opinion? I think that would be a great idea @water. It would make for much less confusion when switching between this, and the main Excel (etc.) UDF. Since it's a global variable, it would also allow for users to (in the rare cases), work with WPS and MS Office at the same time too. (Maybe transferring a WPS doc to MS Office). Since (to the best of my knowledge), the API functions are all the same, it should work seamlessly even if both WPS and MS Office are used at once. Thanks, and Best regards, Donny Edited 13 hours ago by donnyh13 LibreOffice UDF Scite4AutoIt Spell-Checker Using LibreOffice WPS Office adapter — Use MS Word UDFs with WPS Office! LibreOffice API Inspector tools Spoiler "Life is chiefly made up, not of great sacrifices and wonderful achievements, but of little things. It is oftenest through the little things which seem so unworthy of notice that great good or evil is brought into our lives. It is through our failure to endure the tests that come to us in little things, that the habits are molded, the character misshaped; and when the greater tests come, they find us unready. Only by acting upon principle in the tests of daily life can we acquire power to stand firm and faithful in the most dangerous and most difficult positions."
donnyh13 Posted 7 hours ago Author Posted 7 hours ago @water, I got wondering one thing, how would the examples be handled? Have an automatic switch on error from MS Office to WPS compatibility when trying to run Excel_Open, etc? LibreOffice UDF Scite4AutoIt Spell-Checker Using LibreOffice WPS Office adapter — Use MS Word UDFs with WPS Office! LibreOffice API Inspector tools Spoiler "Life is chiefly made up, not of great sacrifices and wonderful achievements, but of little things. It is oftenest through the little things which seem so unworthy of notice that great good or evil is brought into our lives. It is through our failure to endure the tests that come to us in little things, that the habits are molded, the character misshaped; and when the greater tests come, they find us unready. Only by acting upon principle in the tests of daily life can we acquire power to stand firm and faithful in the most dangerous and most difficult positions."
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