Consulting

Results 1 to 8 of 8

Thread: copy from excel to word

  1. #1
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location

    copy from excel to word

    hello
    is there a way to turn an excel workbook into a word document?.
    thanks
    moshe

  2. #2
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    Uh... turn it into a word document, no.

    But if you wanted to copy data from Excel to Word, that can be done. Are you looking to copy over tables, just specific ranges, or everything that's in your workbook?
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  3. #3
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location
    hello
    i want to copy a range of cells into a word documents .
    it mat be a table of data.
    could it be doen through vba?
    thanks
    moshe

  4. #4
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    Put this into an Excel module:

    [vba]Sub PushSelectionToWord()
    Dim wdApp As Object
    Set wdApp = GetObject(, "Word.Application")
    Selection.Copy
    wdApp.Selection.Paste
    Set wdApp = Nothing
    End Sub[/vba]

    Make sure that you only have one instance of Word running, and place the insertion point exactly where you want the data to come in. Save it before you run the macro, just in case you don't like what happens, though.

    Go back to Excel, select the range of cells you want to send over, and run the macro.

    It will create a table in Word of the cells you selected.

    HTH,
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  5. #5
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location
    hello

    thanks for the macro.what about updating the word document if my excek sheet hase changed assumig both are open.
    thanks again
    moshe

  6. #6
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    Well, the easy way would be to delete the stuff that was inserted by the macro and run it again. In this case, there isn't really an easy way to identify what came from the macro, and what didn't...
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  7. #7
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Hi moshe,

    What are you trying to achieve here?

    Your original question asked about 'changing a workbook'. Ken's code copies the Selection, which may be just a part of a workbook.

    If you want a Word document which reflects the latest version of a workbook, what about embedding a link to it rather than copying the contents?
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  8. #8
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Makes sense to me.

Posting Permissions

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