필터 지우기
필터 지우기

How to Apply Numbering to Heading Titles in Word through actxserver

조회 수: 12 (최근 30일)
Kanchibhotla Chandra Sekhar
Kanchibhotla Chandra Sekhar 2019년 8월 12일
댓글: Guillaume 2019년 8월 13일
I am creating a MS word document through actxserver, i have created so Heading in the word using the following code.
word = actxserver('Word.Application'); % Start Word
document = word.Documents.Add; % Create new Document
selection = word.Selection; % Set Cursor
selection.Style = word.ActiveDocument.Styles.Item('Heading 1');
selection.Font.Bold = 1;
selection.Font.Size = 16;
selection.TypeText('Heading 1');
selection.TypeParagraph;
selection.Style = word.ActiveDocument.Styles.Item('Heading 2');
selection.Font.Bold = 1;
selection.Font.Size = 14;
selection.TypeText(GroupName);
selection.TypeParagraph;
In the word documetn it will appear as -
Heading 1
Heading 2
Now i want to add numbering to the Heading in the Word Document through List Format -
selection.Range.ListFormat.ApplyNumberDefault(1);
But i unable to acheive the desired format as -
1. Heading 1
1.1 Heading 2
when i look up the excel sheet objects -
where as in the MATLAB prompt -
So i want to achieve the following List Format -
  1. ListLevelNumber controlled through MATLAB code
  2. ListString controlled through MATLAB code
I have tried many ways using the -
word.ActiveDocument.ListTemplates
Is there any way to get this Headings along with number MATLAB code.
  댓글 수: 4
Kanchibhotla Chandra Sekhar
Kanchibhotla Chandra Sekhar 2019년 8월 13일
편집: Kanchibhotla Chandra Sekhar 2019년 8월 13일
@Guillaume, @dpb i understand your concern regarding the question. I have gone through various questions and implemented in both Stackflow and MS Office API documents. I have tried nearly 2 days in some many ways to implement this. But the problems is, we cannot implement exactly all the API's in the same way as in MATLAB.
I need to know the workaround problems required for this, or am i missing something in implementing this.
Something like this -
Guillaume
Guillaume 2019년 8월 13일
There are two parts to your question:
1) Knowing which Word functions/properties to use to do what you want. This is a question better asked on an Office/Word forum. I don't kniow the Word API well enough to help you there.
2) Coding that into matlab, we can certainly help there once you've got step 1 answered.
If you have VBA (or other language) code that does what you need, then we can translate that.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Use COM Objects in MATLAB에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by