当我将样式应用于段落时,VSTO如何保留数字格式

发布于 2025-02-12 14:39:01 字数 918 浏览 1 评论 0原文

我想更改段落的样式,并保留

开始的数字格式,例如图片:

entry Image Description <此处< /a>

我写下代码以更改示例的样式:

wdapp.Selection.Range.Paragraphs.Style = wdapp.ActiveDocument.Styles(Word.WdBuiltinStyle.wdStyleHeading1)

但是数字格式将被清除(请参见图片示例A) 在此处输入图像描述

当我更改样式时,我该如何保持数字格式?

示例B是我想要的结果(请参阅图片)在此处解决图像描述

以解决Problme,我尝试使用“ ListFormat”恢复,但无用

Dim bh = wdapp.Selection.Range.ListFormat.ListTemplate
wdapp.Selection.Range.Paragraphs.Style = wdapp.ActiveDocument.Styles(Word.WdBuiltinStyle.wdStyleHeading1)
wdapp.Selection.Range.ListFormat.ApplyListTemplate(ListTemplate:=bh)

I want to change the style of paragraphs, and keep the Number Format

For begin like picture:

enter image description here

I write the code below to change style of Example A:

wdapp.Selection.Range.Paragraphs.Style = wdapp.ActiveDocument.Styles(Word.WdBuiltinStyle.wdStyleHeading1)

But the Number Format will be cleard (see picture Example A)
enter image description here

How can I do to keep the Number Format when I change style?

the example B is result what I want (see picture)enter image description here

In order to resolve problme, I try to use "ListFormat" to recover but useless

Dim bh = wdapp.Selection.Range.ListFormat.ListTemplate
wdapp.Selection.Range.Paragraphs.Style = wdapp.ActiveDocument.Styles(Word.WdBuiltinStyle.wdStyleHeading1)
wdapp.Selection.Range.ListFormat.ApplyListTemplate(ListTemplate:=bh)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文