简体   繁体   中英

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.

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

eg This is the String

I want First and last Letters of the String bold

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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