【发布时间】:2021-09-03 03:58:25
【问题描述】:
我是在 matlab 中使用 activex 控件的新手。我试图控制一个word文档。我想我需要帮助在 VBA 语法和 Matlab 之间进行翻译。如何在 matlab 中编写以下代码?
Sub macro()
With CaptionLabels("Table")
.NumberStyle = wdCaptionNumberStyleArabic
.IncludeChapterNumber = True
.ChapterStyleLevel = 1
.Separator = wdSeparatorHyphen
End With
Selection.InsertCaption Label:="Table", TitleAutoText:="", Title:="", _
Position:=wdCaptionPositionAbove, ExcludeLabel:=0
End Sub
谢谢,我查看了帮助和来源,但我仍然感觉很紧张。我希望能够在自动报告中控制标题编号和标题文本。我正在使用表格和数字。我只是不太明白如何编写添加字幕的代码。
下面的代码让我走到了那一步。但我无法控制编号样式等。我试图弄清楚 activex 结构,但我无法理解它。尤其是上面VB子程序的第一位。
% Start an ActiveX session with Word
hdlActiveX = actxserver('Word.Application');
hdlActiveX.Visible = true;
hdlWordDoc = invoke(hdlActiveX.Documents, 'Add');
hdlActiveX.Selection.InsertCaption('Table',captiontext);
【问题讨论】:
标签: matlab vba activex office-interop