Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6629239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:13:54+00:00 2026-05-25T22:13:54+00:00

I am a newbie to using activex controls in matlab. Am trying to control

  • 0

I am a newbie to using activex controls in matlab. Am trying to control a word document. I need help translating between VBA syntax and Matlab, I think. How would one code the following in 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

Thanks, I looked at the help and the source but I am still feeling dense. I want to be able to control caption numbering and caption text in an automated report. Am using Tables and figures. I just can’t quite get my head around how to code the addition of the captions.

The following code gets me part way there. But I don’t have control over numbering style, etc,. I have tried to figure out the activex structure but I can’t make sense of it. In particular, In particular the first bit the VB subroutine above.

% Start an ActiveX session with Word
hdlActiveX = actxserver('Word.Application');
hdlActiveX.Visible = true;
hdlWordDoc = invoke(hdlActiveX.Documents, 'Add');
hdlActiveX.Selection.InsertCaption('Table',captiontext);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:13:55+00:00Added an answer on May 25, 2026 at 10:13 pm

    After some fiddling, I think I got it to work:

    %# 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
    

    Refer to the MSDN documentation to learn how to use this API. For example, the order of arguments of the InsertCaption function used above.

    Note that I had to set IncludeChapterNumber to false, otherwise Word was printing "Error! No text of specified style in document" inside the caption text…

    Finally, to find out the integer values of the wd* enums, I am using the ILDASM tool to disassemble the Office Interop assemblies (as this solution suggested). Simply dump the whole thing to text file, and search for the strings you are looking for.

    ildasm

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Newbie question since I'm not up to speed using maven at all. I'm trying
I'm a newbie to SCons and also using pydev. Can someone help me with
I'm definitely a newbie to ruby (and using 1.9.1), so any help is appreciated.
Absolute newbie question, any help is highly appreciated :) I am using curvycorners (
I am a newbie to using Delphi 2010 to write Ribbon Control... I wanted
i am trying to use OpenMP in my program (i am newbie using OpenMP)
I am a newbie to using jackson library. I am trying to do this
I'm a newbie in using git version control, I got this error when running
a newbie needs some help with logic flow: I'm using the Auto Complete extender
Being a newbie to using matplotlib ,I was trying out some code ,from examples

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.