我正在使用以下代碼在MS Word中使用Delphi XE5插入一個包含2個單元格的表。表格單元格的所有字體都非常簡單。除1字外。我需要這個詞大膽,而其餘的不是。如何在MS Word中使某些文本變爲粗體
請幫我調整我的代碼,這樣我就可以讓1個字加粗。
wrdDoc.Tables.Add(wrdSelection.Range,3,2);
wrdDoc.tables.Item(3).Rows.Alignment := wdAlignRowLeft;
wrdDoc.Tables.Item(3).Columns.Item(1).SetWidth(36,wdAdjustNone);
wrdDoc.Tables.Item(3).Columns.Item(2).SetWidth(379,wdAdjustNone);
wrdDoc.tables.Item(3).Borders.Item(wdBorderLeft).LineStyle := wdLineStyleNone;
wrdDoc.tables.Item(3).Borders.Item(wdBorderRight).LineStyle := wdLineStyleNone;
wrdDoc.tables.Item(3).Borders.Item(wdBorderVertical).LineStyle := wdLineStyleNone;
wrdDoc.tables.Item(3).Borders.Item(wdBorderTop).LineStyle := wdLineStyleNone;
wrdDoc.tables.Item(3).Borders.Item(wdBorderBottom).LineStyle := wdLineStyleNone;
wrdDoc.tables.Item(3).Borders.Item(wdBorderHorizontal).LineStyle := wdLineStyleNone;
wrdDoc.Tables.Item(3).Cell(1,1).Range.InsertAfter('8.1');
wrdDoc.Tables.Item(3).Cell(1,1).Range.Paragraphs.Alignment := wdAlignParagraphleft;
wrdDoc.Tables.Item(3).Cell(1,1).Range.Font.Size := 12;
wrdDoc.Tables.Item(3).Cell(1,1).Range.Font.Bold := false;
wrdDoc.Tables.Item(3).Cell(1,1).Range.Font.underline := false;
wrdDoc.Tables.Item(3).Cell(1,2).Range.InsertAfter('this will not be bold text');
wrdDoc.Tables.Item(3).Cell(1,2).Range.InsertAfter('this will not be bold text');
wrdDoc.Tables.Item(3).Cell(1,2).Range.InsertAfter('THIS TEXT MUST BE BOLD');
wrdDoc.Tables.Item(3).Cell(1,2).Range.Paragraphs.Alignment := wdAlignParagraphJustify;
wrdDoc.Tables.Item(3).Cell(1,2).Range.Font.Size := 12;
wrdDoc.Tables.Item(3).Cell(1,2).Range.Font.Bold := false;
wrdDoc.Tables.Item(3).Cell(1,2).Range.Font.underline := false;
正如你可以在代碼的最後一部分看到,有一個InsertAfter()
3個電話,我插入句子很長。而德爾福限制我到255,所以我只是多次打電話給他們,這和一次打電話一樣好。
只有最後一次調用,必須是粗體。其餘的應該保持上面定義的格式。
任何和所有幫助,將不勝感激。謝謝