How do I change the size of font of a non-english text or numbers in a word document?

2 vues (au cours des 30 derniers jours)
clc
clear
wordApp = actxserver('Word.Application');
wordApp.Visible =true;
doc = wordApp.Documents.Add();
doc.Paragraphs.alignment=1;
for i=1:3
para=doc.Paragraphs.Add;
doc.Paragraphs.Add.Range.Text='سلام';
doc.Paragraphs.Add.Range.Font.Size=16*i;
doc.Paragraphs.Add.Range.InsertParagraphAfter;
end

Réponses (1)

Jack
Jack le 12 Mar 2025
Here’s a concise example of how to insert non-English text (Arabic) into Word and set its font size using MATLAB’s ActiveX interface:
clc
clear
wordApp = actxserver('Word.Application');
wordApp.Visible = true;
% Create a new document
doc = wordApp.Documents.Add;
% Insert three paragraphs of Arabic text at different font sizes
for i = 1:3
para = doc.Paragraphs.Add; % Create a new paragraph
para.Alignment = 1; % Center alignment (optional)
para.Range.Text = 'سلام'; % Non-English text
para.Range.Font.Size = 16*i; % Change font size
end
  • doc.Paragraphs.Add creates a new paragraph and returns a Paragraph object.
  • You can then set Alignment, Text, and Font.Size on para.Range.
  • This works the same way for non-English text or numeric strings.
Follow me so you can message me anytime with future questions. If this helps, please accept the answer and upvote it as well.

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by