将不同的格式合并为一行 Interop.word [英] different format into one single line Interop.word

查看:25
本文介绍了将不同的格式合并为一行 Interop.word的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图弄清楚如何在 c# 中使用 interop.word 将 2 种不同的格式插入到同一段落中,如下所示:

I've been trying to figure out how to insert 2 different formats into the same paragraph using interop.word in c# like this:

你好地球地球这就是我想做的

hello planet earth here's what I want to do

推荐答案

假设您已将文档定义为 oDoc,以下代码应该会得到您想要的结果:

Assuming you have your document defined as oDoc, the following code should get you the desired result:

Word.Paragraph oPara = oDoc.Content.Paragraphs.Add(ref oMissing);
oPara.Range.Text = "hello planet earth here's what I want to do";
object oStart = oPara.Range.Start + 13;
object oEnd = oPara.Range.Start + 18;

Word.Range rBold = oDoc.Range(ref oStart, ref oEnd);
rBold.Bold = 1;

这篇关于将不同的格式合并为一行 Interop.word的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆