ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel to Word Font Size (https://www.excelbanter.com/excel-programming/275063-excel-word-font-size.html)

John Wilson

Excel to Word Font Size
 
Hoping that someone has done this before.

Trying to populate a Word Bookmark with text from Excel.

This works:
Set wordRange = wordDoc.GoTo(What:=wdGoToBookmark, Name:="ltrA")
wordRange.InsertAfter "A"

Now what I'd like to do is set the font on the word document for this
bookmark
to bold. I know that I can have the bookmark in Word preformatted to
bold
but I'd rather be able to do it on-the-fly.
Is this possible?
Are there other formats that can be set, like Underline?

Thanks,
John


John Wilson

Excel to Word Font Size
 
Peter,

That worked!!!!
I was trying this from the wrong angle by things like
Name:="ltrA", Font.Bold:=True
which obviously wasn't working.
After reading your reply, I realized that the
"Set wordRange =" already had me where I needed to be.

For the record, the following worked like a charm:

Set wordRange = wordDoc.GoTo(What:=wdGoToBookmark, Name:="ltrB")
wordRange.Characters(1).Font.Bold = True
wordRange.Characters(1).Font.Underline = True
wordRange.InsertAfter "B"

Thanks,
John


Peter Beach wrote:

Hi John,

I think the Word object model is horrible (and that's mainly because I can
never get it to work properly <g) but how about trying something like:

wordRange.Characters(2).Font.Bold = True

If that works (untested), the Font property has a number of other attributes
like underline etc.

Good luck (always my advice on Word VBA <g),

Peter Beach

"John Wilson" wrote in message
...
Hoping that someone has done this before.

Trying to populate a Word Bookmark with text from Excel.

This works:
Set wordRange = wordDoc.GoTo(What:=wdGoToBookmark, Name:="ltrA")
wordRange.InsertAfter "A"

Now what I'd like to do is set the font on the word document for this
bookmark
to bold. I know that I can have the bookmark in Word preformatted to
bold
but I'd rather be able to do it on-the-fly.
Is this possible?
Are there other formats that can be set, like Underline?

Thanks,
John




All times are GMT +1. The time now is 03:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com