Export a range of cells from Excel into Word

  • Thread starter Konstantin Loguinov
  • Start date
K

Konstantin Loguinov

Folks,

Here is the set up. A have an excel spreadsheet that runs some numbers.
After the numbers are calculated, it creates several tables with the
results. Now, I could simply copy and paste the tables into a word document,
but that's not very efficient. I set up a Word document template that I want
to populate it with a click of a mouse. Here is the code

Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim i As Integer

Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Open("C:\optispeed.doc")
wrdDoc.Bookmarks("General").Range.Text =
Sheets("Results").Range("B2").Value
Set wrdDoc = Nothing
Set wrdApp = Nothing

It works only if I try to export just one cell. However, I want to export a
range of cells and put into a bookmark. Is it possible? If so, what am I
doing wrong?

Thanks!

Konstantin
 
C

Cindy M -WordMVP-

Hi Konstantin,

You're referencing only one cell in your code: Range("B2").Value

you need to reference the entire range, which means specifying the corner cell
on the diagonal. For example: Range("B2", "F10")
Here is the set up. A have an excel spreadsheet that runs some numbers.
After the numbers are calculated, it creates several tables with the
results. Now, I could simply copy and paste the tables into a word document,
but that's not very efficient. I set up a Word document template that I want
to populate it with a click of a mouse. Here is the code

Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim i As Integer

Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Open("C:\optispeed.doc")
wrdDoc.Bookmarks("General").Range.Text =
Sheets("Results").Range("B2").Value
Set wrdDoc = Nothing
Set wrdApp = Nothing

It works only if I try to export just one cell. However, I want to export a
range of cells and put into a bookmark. Is it possible? If so, what am I
doing wrong?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top