Jump to content

Update the Word UDF that comes with AutoIt (former WordEX thread)


water
 Share

Recommended Posts

New versions of Microsoft Office have been released since the last changes were made to the Word UDF. New file types and new functions need to be supported.
This updated version supports Word 2003 up to Word 2010. The latest version of AutoIt is needed to use the latest COM error handler.
Some rarely used functionality has been removed, new functions have and will be added.
The attached PDF shows what's different between Word.au3 and WordEX.au3
You'll find examples for every function ready to run.

Please tell me what you think, about missing functions etc.

2012-07-31 - Version 1.0 - Downloads: 89

First release


2012-08-23 - Version 1.1 - Downloads: 26

New Functions:
  • _Word_DocTableRead: Reads a Word table into a 2D-array
  • _Word_DocTableWrite: Writes a 1D or 2D-array to a Word table

Removed Functions:

  • _Word_MacroRun: Just called the Run method, nothing else, hence removed

 

2012-08-26 - Version 1.2 - Downloads: 277

New Functions:
  • _Word_DocFind: Run or repeat a find operation

 

2012-12-29 - Version 1.3 - Downloads: 937

General:
  • Enhanced error checking
  • Enhanced documentation

New Functions:

  • _Word_DocExport: Exports the document or a range as PDF or XPS

Changed Functions:

  • _Word_Create: Parameter $bForceNew added to create a new instance even if another already exists
  • _Word_DocClose: Defaults for parameters $iSaveChanges and $iOriginalFormat changed to minimize need for user intervention
  • _Word_DocLinkAdd: Default for parameters $oAnchor, $sAddress, $sSubAddress, $sScreenTip, $sTextToDisplay and $sTarget changed from "" or 0 to keyword Default
  • _Word_DocLinkGet: Default for parameter $iIndex changed from -1 to keyword Default

Removed Functions:

  • Unneeded helper functions: CentimetersToPoints, InchesToPoints, LinesToPoints, PicasToPoints, PointsToCentimeters, PointsToInches, PointsToLines, PointsToPicas

 

2013-07-28 - This download page is no longer needed - the rewritten Word UDF is now part of the latest beta version!

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

  • 3 weeks later...

To do:

  • _Word_DocTableFormat: Format a table, columns or rows
To check:
  • Formatting of a range (font, style ...)
  • Shapes
  • Lists
Done:
  • _Word_DocTableWrite: Write a 1D or 2D array to a Word table
  • _Word_DocTableRead: Read the content of a Word table to an array
  • _Word_DocFind: Extended search function
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

Would be nice to see more functions included, f.ex to add shapes.

In that relation, it would be real nice to download and insert all the many many enumerations that Word/Office uses, into a UDF, and possibly also with auto-complete in Scite. (that's my wish for serious Office COM work)

For expansion of this, would you accept change proposals, or just requests ?

I am just a hobby programmer, and nothing great to publish right now.

Link to comment
Share on other sites

I will have a look at shapes. Which functionality do you need?

Enumerations:

I don't think it is sensible to include all enumerations - the list would be too long. WordEXConstants contains all enumerations referenced by a function of the WordEX UDF. I think auto-complete in SciTE isn't very realistic at the moment. But MSDN isn't far away.

I accept all kinds of change proposals, requests ... whatever. You post what you'd like to see and then we discuss if it makes sense to include it ^_^

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

Version 1.1 has been released!

Have fun testing!

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

Is there anything you would like to see in the Word UDF?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

I will have a look at shapes. Which functionality do you need?

I came to this yesterday because I needed to create a test document where placement of shapes on the page was essential (for a test pattern used at work). I gave up the menu hell in Word and ended up programming a macro for it. But it would have been nice to use AutoIT for the purpose, since the job was perfect for scripting.

I think the basic shapes should be enough, although actually there are only two: shape and inlineshape. In your script you only have inlineshape. Difference is that shape hovers over text, and is page-related. inlineshape is text-related, like a char.

There are some 150 different types (according to enumeration), but for most 5-10 basic shapes are used.

Something like

$myShape = _Word_Shape_Add($myDoc, $WdShapeTypeRectangle, 100, 120, 10, 10)
_Word_Shape_Set_Color($myShape, $WdWhite, $WdBlack)

There are MANY options to shapes, so I will have to look a bit deeper into this matter. There are also some definitions to do, f.ex measurements in points/inch/mm/cm/.. ? Insert in document or range ?

Enumerations:

I don't think it is sensible to include all enumerations - the list would be too long. WordEXConstants contains all enumerations referenced by a function of the WordEX UDF. I think auto-complete in SciTE isn't very realistic at the moment. But MSDN isn't far away.

Yes, you are probably right. I actually did not see you already included many of them, my bad.

I accept all kinds of change proposals, requests ... whatever. You post what you'd like to see and then we discuss if it makes sense to include it ^_^

Is discussion about your script HERE or in the general forum ? I mean, Example scripts is for showing your script, not requesting features - or ? I am in doubt about forum rules on that point, who/where do I ask ?

But anyway, a few things:

  • Shape and InlineShape
  • Adding styles to new documents (do not have to be globally stored), and modifying style definitions. I tried to do that myself and failed badly.
  • Working with variables (essentially metadata, MSWord allows up to 65280 unicode chars per var.), and changing document properties
  • Tables (you already have that in the pipeline)

Think this will be a great UDF :)

I am just a hobby programmer, and nothing great to publish right now.

Link to comment
Share on other sites

I think the Word UDF isn't and can never be one of the UDFs that isolates the user completely from the object model. He will have to cope with methods and properties.

The UDF will only have basic functions - everything else has to be done by the user (see the example script _Word_RangeSet.au3 where the UDF makes handling the range a bit easier, but what to do with the range is up to the user and needs some knowledge of the object model).

Shapes:

I will have a look at shapes and if it makes sense to add them to the UDF. The functions should be useful to a lot of people.

Styles:

Maybe later. For now I think we should add the simple things

Variables, document properties:

We removed functions to get/set properties of a document or the Word application because it is only a single line when directly accessing COM

If you have a problem you need to solve post here so we can discuss if this can be solved with a UDF function.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

@water,

Would it be possible to have a function to search for a word which then highlights the word (just like Ctrl+F in word) the first occurrence of the word.

_Word_DocFindReplace just replaces the word in one go.

Also if possible the GoTo functions (Ctrl+G) like GoTo Line, Page, Section (i am not very sure if _Word_DocRangeSet can accomplish some of these tasks).

Also if file menu show/hide, word window size and placement of window could be added.

Regards,

Ajit

Link to comment
Share on other sites

Hi Ajit,

an extended search function is in the pipeline. You will be able to step through the search results and do whatever you need to do with each result.

_Word_DocRangeSet should be able to do what you need (I hope). Just use the correct units from the wdUnit enumeration.

I'm not sure if window handling (size, position) should be part of the Word UDF. Because window handling is one of the core duties of AutoIt itself, right?

Regards

water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

I have an extended find function now that lets you search forward and backward in a specified range.

It doesn't let you wrap the search though. That means you can't continue to search at the beginning of the range when you have reached the end and vice versa.

Might this be a problem for someone?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

Version 1.2 has been released!

Extended Find function (_Word_DocFind) added!

Have fun testing!

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

  • 2 months later...

176 downloads of the latest version - but no error reports, no questions, no complaints :think:

Do you think the UDF is already good enough to replace the Word UDF that comes with AutoIt?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

  • 4 weeks later...

202 downloads of the latest version - but no error reports, no questions, no complaints :think:

Do you think the UDF is already good enough to replace the Word UDF that comes with AutoIt?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

Thanks, glad you like the enhanced UDF :D

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

  • 4 weeks later...

water,

I've use the old _WordDocPropertySet in some of my programs now because of the variety of MS Word versions the programs apply to I'm using the WordEX 1.2 UDF. Is there any reason why I can't include WordEX.au3 and Word.au3 both in order to give me access to _WordDocPropertySet? It doesn't seem to work for me when I use both.

I see that the equivalent has been removed from your program along with _WordDocPropertySet . Does this mean that when/if WordEX 1.2 UDF is adopted these the removed functions will no longer be available?

Thanking you for any information,

jury

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...