使用 activex 在 Word from matlab 中创建一个列表

Create a list in the Word from matlab by using activex

我是在 matlab 中使用 activex 控件的新手。我正在尝试控制一个 word 文档。我需要有关如何在 word 文档中创建列表的帮助。我在word中录制了以下宏。这就是我想从 Matlab 做的。非常感谢您的帮助!

With ListGalleries(wdBulletGallery).ListTemplates(1).ListLevels(1)
    .NumberFormat = ChrW(61623)
    .TrailingCharacter = wdTrailingTab
    .NumberStyle = wdListNumberStyleBullet
    .NumberPosition = InchesToPoints(0.25)
    .Alignment = wdListLevelAlignLeft
    .TextPosition = InchesToPoints(0.5)
    .TabPosition = wdUndefined
    .ResetOnHigher = 0
    .StartAt = 1
    With .Font
        .Bold = wdUndefined
        .Italic = wdUndefined
        .StrikeThrough = wdUndefined
        .Subscript = wdUndefined
        .Superscript = wdUndefined
        .Shadow = wdUndefined
        .Outline = wdUndefined
        .Emboss = wdUndefined
        .Engrave = wdUndefined
        .AllCaps = wdUndefined
        .Hidden = wdUndefined
        .Underline = wdUndefined
        .Color = wdUndefined
        .Size = wdUndefined
        .Animation = wdUndefined
        .DoubleStrikeThrough = wdUndefined
        .Name = "Symbol"
    End With
    .LinkedStyle = ""
End With
ListGalleries(wdBulletGallery).ListTemplates(1).Name = ""
Selection.Range.ListFormat.ApplyListTemplateWithLevel ListTemplate:= _
    ListGalleries(wdBulletGallery).ListTemplates(1), ContinuePreviousList:= _
    False, ApplyTo:=wdListApplyToWholeList, DefaultListBehavior:= _
    wdWord10ListBehavior
Selection.TypeText Text:="asasasasasasas"
Selection.TypeParagraph
Selection.TypeText Text:="asasasasasasas"
Selection.TypeParagraph

结束子

我设法找到了解决方案,发布给需要它的人

word=actxserver('word.application');
word.Visible=true;
myDoc=word.Documents.Add();
listTemp1=myDoc.ActiveWindow.Selection.Range.Application.ListGalleries.Item(2).ListTemplates.Item(1);
listTemp1.ListLevels.Item(1).NumberStyle=1;      
myDoc.ActiveWindow.Selection.Range.ListFormat.ApplyListTemplate(listTemp1,0,0,2);