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 / April 2005

Tip: Looking for answers? Try searching our database.

Get a cell value from excel

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cag - 29 Apr 2005 18:06 GMT
Hi,

Firs of all, thank you for reeding my question. I would like to get a cell
value from a excel file into a word file, using macros programming. I mean,  
developing a macro able to read a cell.

Thanks
Helmut Weber - 29 Apr 2005 20:35 GMT
Hi,

Just the principle:

Sub Test444()
'reference to word library
Dim oWrd As Word.Application
Dim oDoc As Word.Document
 Set oWrd = CreateObject("word.application")
 Set oDoc = oWrd.Documents.Open("c:\test\testdoc.doc")
 ' oWrd.Visible = False
 oDoc.Tables(2).Cell(3, 3).Range.Text = _
 ActiveWorkbook.Worksheets(1).Cells(3, 3).Value
 oDoc.Save
 oDoc.Close
 Set oDoc = Nothing
 oWrd.Quit
 Set oWrd = Nothing
End Sub

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Helmut Weber - 29 Apr 2005 21:20 GMT
Oops,

the example started from Excel.

For a start from Word it would be,
if there is no instance of Excel already active.

Sub Test444()
'reference to Excel library required
Dim oExc As Excel.Application
Dim oWrk As Excel.Workbook
 Set oExc = CreateObject("Excel.application")
 Set oWrk = oExc.Workbooks.Open("c:\test\Excelfile.xls")
 ' oWrd.Visible = False
 ActiveDocument.Tables(1).Cell(1, 1).Range.Text = _
 oWrk.Worksheets(1).Cells(1, 1).Value
 oWrk.Close
 Set oWrk = Nothing
 oExc.Quit
 Set oExc = Nothing
End Sub

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/

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.