Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export data from Excel to Word

Status
Not open for further replies.

darkwraith

Programmer
May 26, 2003
44
IT
Hi, I'm doing a macro starting form MS Word that open a given file xls and copy the content of some cells into a table in the Word document.
After I've opened the file Excel from the Word ile, how can I import the data?
Thanks in advance
Elena
 
How do you open the Excel file ?
I guess you simply have to take a look at OLE Automation.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PH, I've used
Set MyXL = GetObject(, "Excel.Application")
Set MyXL = GetObject("c:\myFile")
to get the xls file. Now I have to select some cells in excel and to put them in a table in word.
Elena
 
Something like this ?
Set MyWB = GetObject("c:\myFile.xls")
MsgBox "A2=" & MyWB.ActiveSheet.Cells(2 , 1)
MyWB.Application.Quit


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi,

Here's a simple example...
Code:
    Set MyWB = GetObject("C:\MyWorkbook.xls")
    ThisDocument.Tables(1).Rows(1).Cells(1).Range.Text = MyWB.Worksheets(1).Cells(1, "D").Value
    Set MyWB = Nothing
Check out the HELP on GetObject. You ALSO need to wheck for the existance of the Excel Application running or not.

Skip,

[glasses] [red]Be advised:[/red] It's been reported that a wee psychic is roaming the countryside.
Small Medium @ Large! [tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top