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

33 次查看(过去 30 天)
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

回答(1 个)

Nagarjuna Manchineni
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 个评论
Steven Lord
Steven Lord 2023-8-16
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 2023-8-16
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Use COM Objects in MATLAB 的更多信息

产品


版本

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by