简体   繁体   English

如何从Excel宏将特定的粗体字符插入Word书签

[英]How to Insert Specific characters bold into a Word Bookmark, from Excel Macro

I am wondering if it is possible to insert into a Word Bookmark, from an Excel Macro specific bold characters of an String. 我想知道是否可以从Excel宏的字符串粗体字符插入Word书签。

With the following code I am able to insert the entire string bold into the Work Bookmark, I want to insert the entire string into the bookmark with some bold characters. 通过以下代码,我可以将整个字符串以粗体插入到工作书签中,我想将整个字符串以一些粗体字符插入到书签中。

String comes from an Excel cell 字符串来自Excel单元格

eg This is the String 例如,这是字符串

I want First and last Letters of the String bold 我想要String的首字母和尾字母加粗

With WordDoc.Bookmarks("vbookmark2").Range
                    .InsertAfter Cells(r, 23).Text
                    .Font.Bold = True
                    '.Characters(30, 2).Font.Bold = True
                    '.Characters(38, 2).Font.Bold = True
 End With

Let's suppose you have the Text that should be displayed in Bookmark in a Variable bmk 假设您有一个文本,该文本应显示在书签中的变量bmk

You can use: 您可以使用:

bmk = "Bookmark"

With bmk

.Characters(Len(bmk), 1).Font.Bold = True
.Characters(1, 1).Font.Bold = True

End With

To bold out the 1st And the Last character. 突出显示第一个和最后一个字符。 You can use this in your code. 您可以在代码中使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM