Jump to content

Recommended Posts

Posted (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 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."

  • Solution
Posted (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 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."

Posted

Added your UDF to the Wiki :) 

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

 

Posted

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?

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

 

Posted (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 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."

Posted

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

Posted (edited)

That's one of the things I have to think about. Maybe create a small GUI to store the flag in an Ini file or reg Key?

BTW: Does anyone have an idea how many people use WPS with AutoIt and the MS Office UDFs?

Edited by water

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

 

Posted

For what it's worth, I had a few hundred downloads on my last file version. (Forgot to write it down). Though it could be repeat downloaders or AI scraping.

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

Posted
On 7/29/2024 at 11:36 PM, donnyh13 said:

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.

Is my understanding correct, that the WPS modification of the MS Office UDFs just should make sure to create/attach to the correct WPS object. 
The modification should not allow to access MS Office AND WPS objects in a single script at the same time?

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

 

Posted
On 10/15/2026 at 6:16 AM, water said:

BTW: Does anyone have an idea how many people use WPS with AutoIt and the MS Office UDFs?

...good question Dorothy. ( I saw my kid grow watching Elmo ) :D 
I used MS office automation in the past ( Office 2003/7 ) for the OCR. When I needed it, found it, used it. And did because it worked, otherwise, next option. So !, think that every one in the world will use it under all circumstances ( of version(s) and environments ) because those that will need it are currently oblivious to the existence of the UDF and their need of it :)

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting  image.gif.922e3a93535f431de08b31ee669cc446.gif
autoit_scripter_blue_userbar.png

Posted
3 minutes ago, argumentum said:

I used MS office automation in the past ( Office 2003/7 ) for the OCR.

...and to replace macro words ( "{{PersonFullName}}" ) until I decided to rename the xdoc to zip, decompress and edit the XML file with the data, then rezip and rename, because it was faster and did not involved using Office in the PC.
Again, this was for Office 2016 ( give or take ). Haven't had such document manipulation project in some years now.

So yes, these UDFs are more useful than you can think, just out of the top of your head.

And since am here, thank y'all for sharing :) 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting  image.gif.922e3a93535f431de08b31ee669cc446.gif
autoit_scripter_blue_userbar.png

Posted (edited)
1 hour ago, water said:

Is my understanding correct, that the WPS modification of the MS Office UDFs just should make sure to create/attach to the correct WPS object. 
The modification should not allow to access MS Office AND WPS objects in a single script at the same time?

If I understand what you're asking, yes, when WPS or MS Office are already running, to make sure the user attaches (e.g. Word_Create, Excel_Open) to the intended program (WPS or MS Office) All this UDF does is make sure that the Object I retrieve by ObjGet("", "Excel.Application") or ObjGet("", "Word.Application"), belongs to WPS, and not MS Office, by checking its install path. Because both MS Office and WPS use the same running Class names, same CLSIDs etc.

When creating a new instance of WPS however, WPS has unique Class names, so the UDF has to use those for ObjCreate.

Quote

(KWPS.Application vs Word.Application; KWPP.Application vs PowerPoint.Application; KET.Application vs Excel.Application).

It's not a problem if both WPS and MSOffice Objects are accessed in the same script at the same time, both use identical API methods, both can be used at the same time independently, but the user needs a way to know what program he is attaching to, to automate.

If I failed to understand your question, feel free to let me know.

Best regards,

Donny

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

Posted
On 10/15/2026 at 4:16 AM, water said:

BTW: Does anyone have an idea how many people use WPS with AutoIt and the MS Office UDFs?

A quick forum search turned up a couple people wishing for the ability:

 

58 minutes ago, argumentum said:

And since am here, thank y'all for sharing :)

Thank you too for all your contributions.

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

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
×
×
  • Create New...