Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2006

Tip: Looking for answers? Try searching our database.

data from Excel cell into Word bookmark

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Luc Weyn - 30 Mar 2006 12:52 GMT
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.

Signature

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

Helmut Weber - 30 Mar 2006 13:37 GMT
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.

Signature

Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000

Shauna Kelly - 30 Mar 2006 13:41 GMT
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/microsoft.public.word.vba.beginners/browse_frm/th
read/f9a9fcee31bc92b4/84174f6a0c42d15e


Hope this helps.

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

> Hello all,
>
[quoted text clipped - 9 lines]
> a
> bookmark in Word. I can't find this info anywhere.
Luc Weyn - 31 Mar 2006 11:50 GMT
Many thanks for a very useful answer. I will have a look at these websites
asap.

Best regards,

Luc

> Hi Luc
>
[quoted text clipped - 8 lines]
>
> For a simple example of putting data from Excel into Word, see

http://groups.google.com/group/microsoft.public.word.vba.beginners/browse_frm/th
read/f9a9fcee31bc92b4/84174f6a0c42d15e


> Hope this helps.
>
[quoted text clipped - 14 lines]
> > a
> > bookmark in Word. I can't find this info anywhere.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.