Writing excel info into MS Word

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

Hi

I need to write out information from cells in Excel into MS Word.

a) Can this be done
b) Can it be done without having MS Word oopen
c) Do I need to have MS Word set up a particular way

If there are some examples somewhere that would be great.

Many Thanks

Steve
 
Thanks

What if the Word document is a form and I need to place the cell info in a
particular place?
 
How to I add a reference to the word library

would this account for the error: User-defined type not defined

Thanks
 
We are coming to the fun part!

Commanding Word means understanding Word's object model (which I don't). I
suggest you perform some experiments. Open the form manually and turn on the
macro recorder. Then practice pasting some information into the fields.
Then stop the recorder and examine the code that results.

Then adapt.
 
Take a look at this:
http://word.mvps.org/FAQs/InterDev/ControlWordFromXL.htm

This too:
http://addbalance.com/usersguide/fields.htm

And this:
http://gregmaxey.mvps.org/Word_Fields.htm

Finally, once you get the DocVariable fields set up in Word (hit Alt + F9 to
see all fields), run this code from Excel.
Sub PushToWord()

Dim objWord As New Word.Application
Dim doc As Word.Document
Dim bkmk As Word.Bookmark
sWdFileName = Application.GetOpenFilename(, , , , False)
Set doc = objWord.Documents.Open(sWdFileName)

With doc
..Variables("VarNumber1").Value = Range("VarNumber1").Value
..Variables("VarNumber2").Value = Range("VarNumber2").Value
'etc
..Range.Fields.Update
End With

'ActiveDocument.Fields.Update

objWord.Visible = True

End Sub

Note: This code runs in Excel; pushes Excel variables (assigned as Named
Ranges) to Word.

Regards,
Ryan--
 
Appreciate this.

many Thanks

ryguy7272 said:
Take a look at this:
http://word.mvps.org/FAQs/InterDev/ControlWordFromXL.htm

This too:
http://addbalance.com/usersguide/fields.htm

And this:
http://gregmaxey.mvps.org/Word_Fields.htm

Finally, once you get the DocVariable fields set up in Word (hit Alt + F9 to
see all fields), run this code from Excel.
Sub PushToWord()

Dim objWord As New Word.Application
Dim doc As Word.Document
Dim bkmk As Word.Bookmark
sWdFileName = Application.GetOpenFilename(, , , , False)
Set doc = objWord.Documents.Open(sWdFileName)

With doc
.Variables("VarNumber1").Value = Range("VarNumber1").Value
.Variables("VarNumber2").Value = Range("VarNumber2").Value
'etc
.Range.Fields.Update
End With

'ActiveDocument.Fields.Update

objWord.Visible = True

End Sub

Note: This code runs in Excel; pushes Excel variables (assigned as Named
Ranges) to Word.

Regards,
Ryan--
 
Back
Top