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 / Mailmerge and Fax / August 2007

Tip: Looking for answers? Try searching our database.

Importing information from excel to word

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ryanadgriffith@hotmail.com - 02 Aug 2007 21:55 GMT
Can anyone help me with a Macro, I have no experience in VBA at all.
I need a macro that will take a numerical value from a cell in excel
and put the vaule where ever I want it in word.  Thanks for your help
Peter Jamieson - 02 Aug 2007 23:12 GMT
Depending on exactly what you need, you may not need a macro. Try...
a. in Excel, open the workbook, select the cell, then Edit|Copy
b. in Word, Edit|Paste Special and select "Paste Link". Then select one of
the options such as Plain text.

A { LINK } field is inserted into the Word document. The result of the LINK
field should be the value in the cell. If you modify the cell content, then
update the LINK field (e.g. by selecting it and pressing F9) the field
result should be updated. You should be able to put such a field most places
in a Word document (although there may be exceptions).

Peter Jamieson
> Can anyone help me with a Macro, I have no experience in VBA at all.
> I need a macro that will take a numerical value from a cell in excel
> and put the vaule where ever I want it in word.  Thanks for your help
ryanadgriffith@hotmail.com - 03 Aug 2007 15:28 GMT
On Aug 2, 6:12 pm, "Peter Jamieson" <p...@KillmapSpjjnet.demon.co.uk>
wrote:
> Depending on exactly what you need, you may not need a macro. Try...
>  a. in Excel, open the workbook, select the cell, then Edit|Copy
[quoted text clipped - 16 lines]
>
> - Show quoted text -

Thanks for your reply, but I dont want to do it that way because I
dont want the values to change everytime I change my excel work sheet.
I want a macro so when I run it, it takes the values from excel and
puts them into word
Peter Jamieson - 03 Aug 2007 16:37 GMT
Well for that you would probably be better off looking in an Excel group for
a comprehensive macro that dealt with all situations (e.g whether or not the
sheet is closed, error handling etc.) but for example you could
a. set a reference to Microsoft Excel 11.0 Object Library (or whichever
version is appropriate)
b. use a function such as

Function getcellvalue(strWBPath As String, _
 strWSname As String, _
 lngRow As Long, _
 lngColumn As Long)
Dim objExcel As Excel.Application
Dim objWB As Excel.Workbook
Dim objWS As Excel.Worksheet

Set objExcel = CreateObject("Excel.Application")
With objExcel
 Set objWB = .Workbooks.Open(FileName:=strWBPath, ReadOnly:=True)
 Set objWS = objWB.Worksheets(strWSname)
 getcellvalue = objWS.Cells(lngRow, lngColumn).Value
 Set objWS = Nothing
 objWB.Close savechanges:=False
 Set objWB = Nothing
End With
objExcel.Quit
Set objExcel = Nothing

End Function

c. call it using e.g.

msgbox getcellvalue("c:\myxlwbs\myxlwb.xls","mysheetname",23,3)

to get the value of row 23 column C

Peter Jamieson
> On Aug 2, 6:12 pm, "Peter Jamieson" <p...@KillmapSpjjnet.demon.co.uk>
> wrote:
[quoted text clipped - 28 lines]
> I want a macro so when I run it, it takes the values from excel and
> puts them into word
 
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.