Insert Text in a MS Word Table from excel

Microsoft Microsoft word 2007
March 24, 2010 at 07:50:26
Specs: Windows XP
Hi Everyone

I have a macro i'm running in excel that loads up a document template i've created. I have a word table at the top of this document that I want to add text to from the excel user form I've designed. My code to select the cell in the table on the word document works but the code to insert the text doesn't.

Can anyone help? Code is below:

Set MyWrd = GetObject(SavePathAndName) 'Open Newly Created Document
MyWrd.Application.Visible = True

'Add Document info to Table Cells
Selection.Text = Issue_box1.Value 'This Line doesn't work

See More: Insert Text in a MS Word Table from excel

Report •

March 24, 2010 at 08:12:02

There is no need to select an item before accessing it, when using VB.

Try this:
MyWrd.Tables(1).Cell(1,2).Range.Text = Issue_box1.Value

Note that Word uses Ranges for it's text, so you need .Range.Text

Hope this helps.


Report •

March 24, 2010 at 08:21:38

That works a treat!! Honestly, Thank you so much! I've been struggling on that one for ages!!!


Report •

March 24, 2010 at 08:31:23
You're Welcome



Report •

Related Solutions

Ask Question