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

23 Ansichten (letzte 30 Tage)
Jonathan Stevenson
Jonathan Stevenson am 22 Mai 2018
Kommentiert: chris am 16 Aug. 2023
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

Antworten (1)

Nagarjuna Manchineni
Nagarjuna Manchineni am 25 Mai 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.
  3 Kommentare
Steven Lord
Steven Lord am 16 Aug. 2023
Can you show us a small example of how you are trying to call these COM interface functions? Are you calling them in a manner similar to the examples on the pages linked in the Microsoft Office section on the Using COM Objects in MATLAB documentation page? Or are you trying to call them directly as though they were regular MATLAB functions, potentially without a COM object instance as input?
The former I would expect to work; the latter I would not necessarily expect to work (if they do work, they may be calling a MATLAB function that shares a name with a COM function but is a different implementation entirely.)
chris
chris am 16 Aug. 2023
I have opened up a new question on this topic with a particular example relating to tabels, but my question is more general than just tabels. See my question: https://www.mathworks.com/matlabcentral/answers/2009417-how-to-use-activex-to-change-ms-word-table-properties

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Use COM Objects in MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by