Export data from excel to word

Jchicoine

New Member
Joined
Apr 29, 2002
Messages
22
Hi ! I'm looking for a macro or a way to export info from a cell in MsExcel to a cell in a form in MsWord.

Thanks !
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Probably easier the other way around. Import the information from Excel into Word.

Try simple links.
1) Create your XLS
2) Create your DOC
3) One at a time, paste link each cell from the XLS into the appropriate place in the DOC.

If you have a table of data on sheet 1 in the XLS that you want to create several forms from, then the linked XLS cells should be on sheet 2 (for ex.) The cells on sheet 2 would contain Vlookup (or similar) equations that will lookup the information from the table. The Vlookup would look at a cell on sheet 2 to determine which row to obtain from the table. Now, If that cell can be a link pasted from the word doc, then if you change the name in the word doc, then update excel, then update word, you should be able to page through the table from word.

I have never tried this, but it should work. I expect that someone else could offer you a slicker VBA way of do this.

Ex:

DOC==============
NAME: John
DATE OF BIRTH: = [c:/dir/file.xls]Sheet2!$B$2
CITY OF BIRTH: = [c:/dir/file.xls]Sheet2!$B$3

XLS SHEET 1=============
NAME DATE OF BIRTH CITY OF BIRTH
John 1909 San Francisco
Frank 1999 New York
etc.

XLS SHEET 2============
A1(NAME)=C:/dir/file.doc ..?. (manually paste link)

B1(NAME) =vlookup(A1,Sheet1Table,1)
B2(DATE OF BIRTH) =vlookup(A1,Sheet1Table,2)
etc.

Cheers,

Brian
 
Upvote 0
You can play with the following sample code:

Code:
Sub WordUp()
Dim WdObj As Object, fname As String
fname = Sheets(2).[a1].Value
Set WdObj = CreateObject("Word.Application")
WdObj.Visible = False
Sheets(1).UsedRange.Copy
WdObj.documents.Add
WdObj.Selection.Paste
Application.CutCopyMode = False
If fname <> "" Then 'make sure fname is not blank
With WdObj
    .ChangeFileOpenDirectory "c:temp"
    .ActiveDocument.SaveAs Filename:=fname & ".doc"
End With
Else:
MsgBox ("File not saved, naming range was botched, guess again.")
End If
With WdObj
    .ActiveDocument.Close False
    .Quit
End With
Set WdObj = Nothing
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,491
Messages
6,113,963
Members
448,536
Latest member
CantExcel123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top