data from Excel cell into Word bookmark

L

Luc Weyn

Hello all,

I am looking to find a method to do the following:

I have an Excel spreadsheet. In this spreadsheet I have a number of cells
that contain, calculated, information. In order to publish this information
in a convenient way, I would like to do this with a Word document, rather
than formatting a document in Excel.

All I need to have is to find the code to import the contents of a cell to a
bookmark in Word. I can't find this info anywhere.

--
Imexgra vzw
Borzestraat 29
B-2000 Antwerpen
Tel.: +32 (0)3 233 43 93
Fax: +32 (0)3 233 34 60
http://www.imexgra.org
 
H

Helmut Weber

Hi Luc,

not quite simple.

Here is just the principle for getting something
from Excel into an encluding bookmark, like [TextText].

Sub ExcelinWord2()
' reference to Excel library set !
Dim oExlApp As Excel.Application
Dim oExlWrk As Excel.Workbook
Dim oExlSht As Excel.Worksheet
Dim oExlVal As String
Dim oWrdRng As Range

Set oExlApp = New Excel.Application
Set oExlWrk = oExlApp.Workbooks.Open("c:\test\excel\keller-01.xls")
Set oExlSht = oExlWrk.Sheets(1)

oExlVal = oExlSht.Cells(1, 1).Value

oExlWrk.Close
oExlApp.Quit
Set oExlApp = Nothing
Set oExlWrk = Nothing
Set oExlSht = Nothing

With ActiveDocument.Range.Bookmarks("Mark01")
Set oWrdRng = .Range
.Range.Text = oExlVal
oWrdRng.End = oWrdRng.start + Len(oExlVal)
oWrdRng.Bookmarks.Add Name:="Mark01"
End With

End Sub

Ask again, if you need further help or clarification.
 
S

Shauna Kelly

Hi Luc

You can do this by controlling Word from Excel or vice versa. For example,
see:
Control Excel from Word
http://www.word.mvps.org/FAQs/InterDev/ControlXLFromWord.htm

For information on inserting text into a bookmark, see
Inserting text at a bookmark without deleting the bookmark
http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm

For a simple example of putting data from Excel into Word, see
http://groups.google.com/group/micr..._frm/thread/f9a9fcee31bc92b4/84174f6a0c42d15e

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
L

Luc Weyn

Many thanks for a very useful answer. I will have a look at these websites
asap.

Best regards,

Luc
 

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