Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: Export data from excel to word

  1. #1
    New Member
    Join Date
    Apr 2002
    Posts
    22
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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 !

  2. #2
    Board Regular
    Join Date
    Apr 2002
    Posts
    113
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default

    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

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    if you need code check the Microsoft file thats default installed with office

    samples.xls
    Free Excel based Web Toolbar available here.

    Jack in the UK
    J & R Excel Solutions
    "making Excel work for you"

  4. #4
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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

  5. #5
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    NAte has given nice code more of less the sane as samples it creates word as an object...


    Free Excel based Web Toolbar available here.

    Jack in the UK
    J & R Excel Solutions
    "making Excel work for you"

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •