ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automate Word via Excel (https://www.excelbanter.com/excel-programming/294454-automate-word-via-excel.html)

John Wilson

Automate Word via Excel
 
All,

Been trying to do this for a while with no luck. Maybe someone has run into
this before??

In Word, I have a cell within a table.

I populate it via Excel with:
Set wordRange = wordDoc.GoTo(What:=-1, Name:="line2")
wordRange.InsertAfter BodyTB2
Set wordRange = wordDoc.GoTo(What:=-1, Name:="line2A")
wordRange.InsertAfter "ABC"

The above works well, but what I'm trying to accomplish is to have
"only" the "ABC" underlined. Within that cell in Word, if I set the
second bookmark as "Underlined", it won't hold the underlined
setting. Whatever the first bookmark setting is takes priority for
the whole cell.

I've tried multiple bookmarks, insert before and after the bookmark,
all sorts of formats, etc. and can't get it to work. I can't split the cell
(which would work) because I need the "ABC" to follow directly
after the the initial text that's placed in that cell.

Any ideas on how to accomplish this???

Thanks,
John




John Wilson

Automate Word via Excel
 
Just now got it to work.....finally !!!!!

Set wordRange = wordDoc.GoTo(What:=-1, Name:="line2")
wordRange.InsertAfter BodyTB2
Set wordRange = wordDoc.GoTo(What:=-1, Name:="line2A")
wordRange.InsertAfter "ABC"
wordRange.Font.Bold = True
wordRange.Font.Underline = True



"John Wilson" wrote in message
...
All,

Been trying to do this for a while with no luck. Maybe someone has run

into
this before??

In Word, I have a cell within a table.

I populate it via Excel with:
Set wordRange = wordDoc.GoTo(What:=-1, Name:="line2")
wordRange.InsertAfter BodyTB2
Set wordRange = wordDoc.GoTo(What:=-1, Name:="line2A")
wordRange.InsertAfter "ABC"

The above works well, but what I'm trying to accomplish is to have
"only" the "ABC" underlined. Within that cell in Word, if I set the
second bookmark as "Underlined", it won't hold the underlined
setting. Whatever the first bookmark setting is takes priority for
the whole cell.

I've tried multiple bookmarks, insert before and after the bookmark,
all sorts of formats, etc. and can't get it to work. I can't split the

cell
(which would work) because I need the "ABC" to follow directly
after the the initial text that's placed in that cell.

Any ideas on how to accomplish this???

Thanks,
John







All times are GMT +1. The time now is 10:41 AM.

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