+ Reply to Thread
Results 1 to 7 of 7

Code to copy Excel data to a Word document

  1. #1
    Forum Contributor
    Join Date
    02-01-2008
    Location
    Perth, Australia
    MS-Off Ver
    Excel 365
    Posts
    135

    Question Code to copy Excel data to a Word document

    Hi All,

    If possible could someone please tell me why the below code is not calling the normal.doc macro "testy" and any solutions
    The code opens a new document, pastes the text from the clipboard and then fails to run the wanted macro.

    Any help is appreciated


    Please Login or Register  to view this content.
    Cheers
    Last edited by Zimbo; 04-09-2009 at 03:31 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: CopyXLSDataToWorddoc

    Hello zimbo,

    It isn't clear to me what you are doing. Is "testy" a macro in another Word Document or is it the data on the clipboard that you have pasted or something else? Whenever you encounter an error, please include the error number. Include the error message too, if you can.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: CopyXLSDataToWorddoc

    The method works fine for me. Comment that line out and check that your Normal.Dot's Module1 testy sub exists.

    You could add a Normal.dot Module1 Sub Hi to test run.
    Please Login or Register  to view this content.
    And then change your Run in the Excel code to:
    Please Login or Register  to view this content.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: CopyXLSDataToWorddoc

    Zimbo,

    The name of your macro is not a suitable thread title. Please read the forum rules about thread titles, and then amend your post accordingly.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Contributor
    Join Date
    02-01-2008
    Location
    Perth, Australia
    MS-Off Ver
    Excel 365
    Posts
    135

    Re: Code to copy Excel data to a Word document

    Hi Leith,

    The macro creates a new word document and then dumps the clipboard into this document. The "testy" macro is located in the Normal.doc document and is is designed to format this new Word document.

    Appologies on not mentioning the error.
    The error being received is:
    Please Login or Register  to view this content.
    Cheers

  6. #6
    Forum Contributor
    Join Date
    02-01-2008
    Location
    Perth, Australia
    MS-Off Ver
    Excel 365
    Posts
    135

    Unhappy Re: Code to copy Excel data to a Word document

    Hi Kenneth,

    I have tried your code which does the same as mine in a fresh workbook and word document to see if I was going crazy and it is still coming up with the error code mentioned in the above post.

    Help Please

  7. #7
    Forum Contributor
    Join Date
    02-01-2008
    Location
    Perth, Australia
    MS-Off Ver
    Excel 365
    Posts
    135

    Lightbulb Re: Code to copy Excel data to a Word document

    Hi All,

    I have removed the reference to the Normal and Module 1 in the word call section and it now works perfectly.

    Please Login or Register  to view this content.
    Thanks for the help

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1