+ Reply to Thread
Results 1 to 9 of 9

Export data from Excel to word

  1. #1
    Registered User
    Join Date
    10-26-2007
    Posts
    55

    Export data from Excel to word

    Hi,

    I'm looking to convert the follow macro to instead of creating a new word document each time but to add each row to the same word document. I'm just starting to learn VBA and found the script on MRExcel site.

    Please Login or Register  to view this content.
    Am i thinking along the correct lines that i would need to create the word document first before the FOR loop and then add each to the word document in the Loop?

    Any help would be appreciated.
    Last edited by delboy2405; 01-14-2012 at 05:38 AM. Reason: solved

  2. #2
    Registered User
    Join Date
    10-26-2007
    Posts
    55

    Re: Export data from Excel to word

    Hi Managed to solve the issue myself, what i've noticed when running the macro is that it gets an error if a word document is already open. How would I get the macro to check for a word document and close it first

  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Export data from Excel to word

    Please Login or Register  to view this content.



  4. #4
    Registered User
    Join Date
    01-15-2010
    Location
    VA, USA
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Export data from Excel to word

    snb: I don't understand that code for resolving the question he had...I certainly could misunderstand it though. Here is the code I was thinking would solve the issue where it would close any instance of word that was open. I'm on word 2003

    Please Login or Register  to view this content.
    Last edited by vthokie2010; 01-13-2012 at 02:04 PM.

  5. #5
    Registered User
    Join Date
    10-26-2007
    Posts
    55

    Re: Export data from Excel to word

    thanks vthokie2010

    getting a different issue at the moment

    When running the code below i'm getting error run time 4605 error code, i dont think i've changed anything since it was working ok, apart from putting the line
    Please Login or Register  to view this content.
    But even when i comment out error appears, it also seems to happening randomly as it runs through the data on the loop

    Full code

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    10-26-2007
    Posts
    55

    Re: Export data from Excel to word

    Looks like it gets the error at line

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-15-2010
    Location
    VA, USA
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Export data from Excel to word

    Maybe try this in place of that line of code
    Please Login or Register  to view this content.
    if not let me know and I'll look at sometime over the weekend or monday.

  8. #8
    Registered User
    Join Date
    10-26-2007
    Posts
    55

    Re: Export data from Excel to word

    unfortunately doesn't seem to work, when run code get an 438 error message.

  9. #9
    Registered User
    Join Date
    10-26-2007
    Posts
    55

    Re: Export data from Excel to word

    looks like the issue has been solved, I went to tools > References and unticked word object library. Restarted Excel and then ticked again. Seems to be running fine now

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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