MATLAB Answers


ActiveX Syntax for Word Tables (Cursor Position, Sub-tables, etc.)

Asked by Jonathan Stevenson on 22 May 2018
Latest activity Answered by Nagarjuna Manchineni on 25 May 2018
I'm trying to automatically create a set of Word Tables from data. I'm almost there, but need a few additional ActiveX commands/procedures to accomplish what I want to do. I assume that whatever we can do manually in Word should be possible through equivalent ActiveX commands?
First of all, is there a set of formal documentation on the ActiveX syntax? I've seen tons of samples/examples here and elsewhere which hints at quite a lot more commands than what I've found here (Mathworks).
For example, what are the ActiveX Word syntax (to use in a MATLAB script) that are equivalent to pressing either End or Home on a keyboard (i.e. to position the cursor at either the beginning or end of a line of text/cell entry in a table)?
Also, I need to create a series of smaller "sub-tables" in certain cells in a parent Table. I can do this fine manually, but trying to automate what is quickly becoming a very arduous (and error-prone) task. What is the correct ActiveX command sequence to do this?
Thanks in advanced!
Jonathan D. Stevenson, Ph.D. Pratt and Whitney Canada


Sign in to comment.




1 Answer

Answer by Nagarjuna Manchineni on 25 May 2018

Hi Johnathan,
'actxserver(progid)' MATLAB command creates a local OLE Automation server, where progid is the programmatic identifier (ProgID) of an OLE-compliant COM server. The function returns a handle to the default interface of the server.
As an info, the Microsoft® Component Object Model (COM) provides a framework for integrating reusable, binary software components into an application. A COM object has properties, methods, events, and interfaces. Vendor documentation (in your case Microsoft word) describes these features.
The following link provides the different references of the MS word object model. You can use the methods that are exposed on the object to achieve the desired workflow:
You can also learn about your object using MATLAB® commands.
Example of writing to word from MATLAB:
There is an example that is a MATLAB Central Submission. The submission can be found at the link below.
The submission also shows how to insert figures, tables, headers and footers, etc.


Sign in to comment.