Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After some fiddling, I think I got it to work:</p> <pre class="lang-sh prettyprint-override"><code>%# open Word Word = actxserver('Word.Application'); Word.Visible = true; %# create new document doc = Word.Documents.Add; %# set caption style for tables t = Word.CaptionLabels.Item(2); %# 1:Figure, 2:Table, 3:Equation t.NumberStyle = 0; %# wdCaptionNumberStyleArabic t.IncludeChapterNumber = false; t.ChapterStyleLevel = 1; t.Separator = 0; %# wdSeparatorHyphen %# insert table caption for current selection Word.Selection.InsertCaption('Table', '', '', 0, false) %# wdCaptionPositionAbove %# save document, then close doc.SaveAs2( fullfile(pwd,'file.docx') ) doc.Close(false) %# quit and cleanup Word.Quit Word.delete </code></pre> <p>Refer to the MSDN documentation to learn how to use this API. For example, the order of arguments of the <a href="http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.selection.insertcaption.aspx" rel="nofollow noreferrer">InsertCaption</a> function used above.</p> <p>Note that I had to set <code>IncludeChapterNumber</code> to false, otherwise Word was printing <code>"Error! No text of specified style in document"</code> inside the caption text...</p> <p>Finally, to find out the integer values of the <code>wd*</code> enums, I am using the ILDASM tool to disassemble the Office Interop assemblies (as <a href="https://stackoverflow.com/questions/7097358/enum-values-for-office-interop-via-dynamic-object/7097508#7097508">this solution</a> suggested). Simply dump the whole thing to text file, and search for the strings you are looking for.</p> <p><img src="https://i.stack.imgur.com/jzco0.png" alt="ildasm"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload